calendar.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,905 行 · 第 1/5 页

PHP
1,905 行
字号
        	$day_output .= $this->ipsclass->compiled_templates['skin_calendar']->cal_day_bit($day);        }                $cal_output = $this->get_month_events($this->chosen_month, $this->chosen_year);                //-----------------------------------------        // Switch the HTML tags...        //-----------------------------------------               $this->output = str_replace( "<!--IBF.DAYS_TITLE_ROW-->", $day_output, $this->output );        $this->output = str_replace( "<!--IBF.DAYS_CONTENT-->"  , $cal_output, $this->output );                $this->output = str_replace( "<!--IBF.MONTH_BOX-->"     , $this->get_month_dropdown(), $this->output );        $this->output = str_replace( "<!--IBF.YEAR_BOX-->"      , $this->get_year_dropdown() , $this->output );                //-----------------------------------------        // Get prev / this / next calendars        //-----------------------------------------                $this->output = str_replace( "<!--PREV.MONTH-->", $this->get_mini_calendar( $prev_month['month_id'], $prev_month['year_id'] ), $this->output );        $this->output = str_replace( "<!--THIS.MONTH-->", $this->get_mini_calendar( $this->chosen_month    , $this->chosen_year     ), $this->output );        $this->output = str_replace( "<!--NEXT.MONTH-->", $this->get_mini_calendar( $next_month['month_id'], $next_month['year_id'] ), $this->output );        	        $this->nav[] = "<a href='{$this->ipsclass->base_url}act=calendar'>{$this->ipsclass->lang['page_title']}</a>";        $this->nav[] = $this->month_words[$this->chosen_month - 1]." ".$this->chosen_year;    }        /*-------------------------------------------------------------------------*/    // POST NEW CALENDAR EVENT    /*-------------------------------------------------------------------------*/        function cal_event_form( $type='add' )    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$event_id      = intval( $this->ipsclass->input['event_id'] );    	$calendar_id   = intval( $this->ipsclass->input['calendar_id'] );    	$form_type     = $this->ipsclass->input['formtype'];    	$recur_menu    = "";    	$calendar_jump = "";    	$divhide	   = "none";    	    	//-----------------------------------------    	// CHECK    	//-----------------------------------------    	    	if ( $this->ipsclass->member['g_calendar_post'] != 1)		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				if ( ! $this->ipsclass->member['id'])		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				//-----------------------------------------		// Got permission to post to this calendar?		//-----------------------------------------				$this->build_permissions( $calendar_id );				if ( ! $this->can_post )		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_permission') );		}				//-----------------------------------------		// Edit calendar option		//-----------------------------------------				foreach( $this->calendar_cache as $id => $data )		{			if ( $this->ipsclass->check_perms( $data['perm_post'] ) == TRUE AND $this->ipsclass->check_perms( $data['perm_read'] ) == TRUE )			{				$selected       = $calendar_id == $data['cal_id'] ? ' selected="selected" ' : '';				$calendar_jump .= "<option value='{$data['cal_id']}'{$selected}>{$data['cal_title']}</option>\n";			}		}		    	//-----------------------------------------    	// WHICHISIT    	//-----------------------------------------    	    	if ( $type == 'add' )    	{			$tmp = explode( "-", $this->ipsclass->input['nd'] );						$nd = intval( $tmp[2] );			$nm = intval( $tmp[1] );			$ny = intval( $tmp[0] );						$public  = "";			$private = "";			$event   = array( 'event_smilies' => 1, 'event_content' => '' );						$fd = $nd = $nd ? $nd : $this->now['mday'];			$fm = $nm = $nm ? $nm : $this->now['mon'];			$fy = $ny = $ny ? $ny : $this->now['year'];						$tz_offset  = ( $this->ipsclass->member['time_offset'] != "" ) ? $this->ipsclass->member['time_offset'] : $this->ipsclass->vars['time_offset'];						$recur_menu = "<option value='1'>{$this->ipsclass->lang['fv_days']}</option><option value='2'>{$this->ipsclass->lang['fv_months']}</option><option value='3'>{$this->ipsclass->lang['fv_years']}</option>";			$code       = 'addnewevent';			$button     = $this->ipsclass->lang['calendar_submit'];						$event['event_timeset'] = "";		}		else		{			if ( ! $event_id )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );			}						//-----------------------------------------			// Get the event			//-----------------------------------------						$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'cal_events', 'where' => "event_id=$event_id" ) );			$this->ipsclass->DB->simple_exec();						if ( ! $event = $this->ipsclass->DB->fetch_row() )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );			}						//-----------------------------------------			// Do we have permission to edit this event?			//-----------------------------------------						if ( $this->ipsclass->member['id'] == $event['event_member_id'] )			{				$can_edit = 1;			}			else if ( $this->ipsclass->member['g_is_supmod'] == 1 )			{				$can_edit = 1;			}			else			{				$can_edit = 0;			}						if ( $can_edit != 1 )			{ 				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );			}						//-----------------------------------------			// Do we have permission to see the event?			//-----------------------------------------						if ( $event['event_perms'] != '*' )			{				if ( ! preg_match( "/(^|,)".$this->ipsclass->member['mgroup']."(,|$)/", $event['event_perms'] ) )				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'cal_no_events') );				}			}						$tz_offset = $event['event_tz'];						//-----------------------------------------			// Date stuff			//-----------------------------------------						$convert_hours = 0;						if( $event['event_timeset'] )			{				$divhide = "";				$hour_min = explode(":", $event['event_timeset']);				$convert_hours = ($hour_min[0] * 3600) + ($hour_min[1] * 60);			}						if( $tz_offset && $event['event_timeset'] )			{				$convert_hours = $tz_offset * 3600 + $convert_hours;			}						$_unix_from = explode('-', gmdate('n-j-Y', $event['event_unix_from'] - $convert_hours ));			if( $convert_hours && $event['event_unix_to'] )			{				$event['event_unix_to'] -= $convert_hours;			}			$_unix_to   = explode('-', gmdate('n-j-Y', $event['event_unix_to']  ));			$nd = $_unix_from[1];			$nm = $_unix_from[0];			$ny = $_unix_from[2];						$fd = $_unix_to[1];			$fm = $_unix_to[0];			$fy = $_unix_to[2];						//-----------------------------------------			// Form stuff			//-----------------------------------------						if ( $event['event_recurring'] )			{				$form_type = 'recur';			}			else if ( ! $event['event_recurring'] AND $event['event_unix_to'] )			{				$form_type = 'range';			}			else			{				$form_type = 'single';			}						//-----------------------------------------			// Private?			//-----------------------------------------						if ( $event['event_private'] == 1 )			{				$private = ' selected';			}			else			{				$public = ' selected';			}						//-----------------------------------------			// Recur stuff			//-----------------------------------------						$recur_menu .= $event['event_recurring'] == '1' ? "<option value='1' selected='selected'>{$this->ipsclass->lang['fv_days']}</option>"															: "<option value='1'>{$this->ipsclass->lang['fv_days']}</option>";																	$recur_menu .= $event['event_recurring'] == '2' ? "<option value='2' selected='selected'>{$this->ipsclass->lang['fv_months']}</option>"															: "<option value='2'>{$this->ipsclass->lang['fv_months']}</option>";																	$recur_menu .= $event['event_recurring'] == '3' ? "<option value='3' selected='selected'>{$this->ipsclass->lang['fv_years']}</option>"															: "<option value='3'>{$this->ipsclass->lang['fv_years']}</option>";			$code   = 'doedit';			$button = $this->ipsclass->lang['calendar_edit_submit'];		}				//-----------------------------------------		// Do TZ form		//-----------------------------------------				$this->ipsclass->load_language( 'lang_ucp' );		 		$time_select = "<select name='event_tz' class='forminput'>"; 		 		//----------------------------------------- 		// Loop through the langauge time offsets and names to build our 		// HTML jump box. 		//----------------------------------------- 		 		foreach( $this->ipsclass->lang as $off => $words ) 		{ 			if ( preg_match("/^time_(-?[\d\.]+)$/", $off, $match)) 			{				$time_select .= $match[1] == $tz_offset ? "<option value='{$match[1]}' selected='selected'>$words</option>\n"												        : "<option value='{$match[1]}'>$words</option>\n"; 			} 		} 		 		$time_select .= "</select>";				//-----------------------------------------		// Start off nav		//-----------------------------------------				$this->nav[] = "<a href='{$this->ipsclass->base_url}act=calendar'>{$this->ipsclass->lang['page_title']}</a>";		$this->nav[] = $this->ipsclass->lang['post_new_event'];				//-----------------------------------------		// Start off form		//-----------------------------------------				$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_start_form( $code, $this->calendar_id, $form_type, $event_id );				$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->table_top($this->ipsclass->lang['post_new_event']);		$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_event_title( $event['event_title'] );				//-----------------------------------------		// Alright... Which form type?		//-----------------------------------------				if ( $form_type == 'single' )		{			$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_choose_date_single(																			       $this->get_day_dropdown($nd), $this->get_month_dropdown($nm), $this->get_year_dropdown($ny) );		}		else if ( $form_type == 'range' )		{			$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_choose_date_range(																				   $this->get_day_dropdown($nd), $this->get_month_dropdown($nm), $this->get_year_dropdown($ny),																				   $this->get_day_dropdown($fd), $this->get_month_dropdown($fm), $this->get_year_dropdown($fy)  );		}		else		{			$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_choose_date_recur(																				   $this->get_day_dropdown($nd), $this->get_month_dropdown($nm), $this->get_year_dropdown($ny),																				   $recur_menu,																				   array(																						  'd' => $this->get_day_dropdown($fd),																						  'm' => $this->get_month_dropdown($fm),																						  'y' => $this->get_year_dropdown($fy)																						)  );		}				$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_event_type( $public, $private, $time_select, $this->calendar_jump, 								array('formtype' => $form_type, 'timestart' => $event['event_timeset'], 'divhide' => $divhide, 'checked' => $divhide == '' ? "checked='checked'" : '' ) );				if ($this->ipsclass->member['mgroup'] == $this->ipsclass->vars['admin_group'])		{			//-----------------------------------------			// Get all the group ID's and names from			// the DB and build the selection box			//-----------------------------------------						$group_choices = "";						foreach( $this->ipsclass->cache['group_cache'] as $i => $r )			{				$selected = "";								if ( preg_match( "/(^|,)".$r['g_id']."(,|$)/", $event['event_perms'] ) )				{					$selected = ' selected';				}								$group_choices .= "<option value='".$r['g_id']."'".$selected.">".$r['g_title']."</option>\n";			}						$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_admin_group_box($group_choices);		}				//-----------------------------------------		// Using RTE? Convert BBCode to HTML		//-----------------------------------------				if ( $event['event_content'] )		{			if ( $this->post->han_editor->method == 'rte' )			{				$this->post->parser->parse_html    = 0;				$this->post->parser->parse_smilies = intval($event['event_smilies']);				$this->post->parser->parse_bbcode  = 1;				$event['event_content'] = $this->post->parser->pre_db_parse( $event['event_content'] );				$event['event_content'] = $this->post->parser->convert_ipb_html_to_html( $event['event_content'] );				}			else			{				$event['event_content'] = $this->ipsclass->my_br2nl($event['event_content']);			}		}				//-----------------------------------------		// Generate text editor		//-----------------------------------------				$this->output .= $this->post->html_add_smilie_box( $this->post->html_post_body( $event['event_content'] ) );				$this->output  = str_replace( '<!--IBF.EMO-->'  , $this->ipsclass->compiled_templates['skin_post']->get_box_enableemo( $event['event_smilies'] ? 'checked="checked"' : "" )  , $this->output );				$this->output .= $this->ipsclass->compiled_templates['skin_calendar']->calendar_end_form( $button );	}		    /*-------------------------------------------------------------------------*/    // ADD NEW CALENDAR EVENT TO THE DB    /*-------------------------------------------------------------------------*/        function cal_event_save( $type='add' )    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$read_perms   = '*';

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?