⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icalcreator.class.php

📁 完美的在线教育系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php/*********************************************************************************//** * iCalcreator class v2.4.3 * copyright (c) 2007-2008 Kjell-Inge Gustafsson kigkonsult * www.kigkonsult.se/iCalcreator/index.php * ical@kigkonsult.se * * Description: * This file is a PHP implementation of RFC 2445. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *//*********************************************************************************//*********************************************************************************//*         A little setup                                                        *//*********************************************************************************/            /* your local language code */// define( 'ICAL_LANG', 'sv' );            // alt. autosetting/*$langstr     = $_SERVER['HTTP_ACCEPT_LANGUAGE'];$pos         = strpos( $langstr, ';' );if ($pos   !== false) {  $langstr   = substr( $langstr, 0, $pos );  $pos       = strpos( $langstr, ',' );  if ($pos !== false) {    $pos     = strpos( $langstr, ',' );    $langstr = substr( $langstr, 0, $pos );  }  define( 'ICAL_LANG', $langstr );}*/            /* only for phpversion 5.x, date management, default timezone setting */if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) {  date_default_timezone_set( 'Europe/Stockholm' );            /* version string, do NOT remove!! */define( 'ICALCREATOR_VERSION', 'iCalcreator 2.4.3' );/*********************************************************************************//*********************************************************************************//** * vcalendar class * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.13 - 2007-12-30 */class vcalendar {            //  calendar property variables  var $calscale;  var $method;  var $prodid;  var $version;  var $xprop;            //  container for calendar components  var $components;            //  component config variables  var $allowEmpty;  var $unique_id;  var $language;  var $directory;  var $filename;  var $url;  var $delimiter;  var $nl;  var $format;            //  component internal variables  var $attributeDelimiter;  var $valueInit;            //  component xCal declaration container  var $xcaldecl;/* * constructor for calendar object * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.13 - 2007-12-30 * @return void */  function vcalendar () {    $this->_makeVersion();    $this->calscale   = null;    $this->method     = null;    $this->_makeUnique_id();    $this->prodid     = null;    $this->xprop      = array();/** *   language = <Text identifying a language, as defined in [RFC 1766]> */    if( defined( 'ICAL_LANG' ))      $this->setConfig( 'language', ICAL_LANG );    $this->setConfig( 'allowEmpty', TRUE );    $this->setConfig( 'nl',         "\n" );    $this->setConfig( 'format',     'iCal');    $this->directory  = null;    $this->filename   = null;    $this->url        = null;    $this->setConfig( 'delimiter',  DIRECTORY_SEPARATOR );    $this->xcaldecl   = array();    $this->components = array();  }/*********************************************************************************//** * Property Name: CALSCALE *//** * creates formatted output for calendar property calscale * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.9.7 - 2006-11-20 * @return string */  function createCalscale() {    if( !isset( $this->calscale ))      return;    switch( $this->format ) {      case 'xcal':        return ' calscale="'.$this->calscale.'"'.$this->nl;        break;      default:        return 'CALSCALE:'.$this->calscale.$this->nl;        break;    }  }/** * set calendar property calscale * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-13 * @param string $value * @return void */  function setCalscale( $value ) {    $this->calscale = $value;  }/*********************************************************************************//** * Property Name: METHOD *//** * creates formatted output for calendar property method * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.9.7 - 2006-11-20 * @return string */  function createMethod() {    if( !isset( $this->method ))      return;    switch( $this->format ) {      case 'xcal':        return ' method="'.$this->method.'"'.$this->nl;        break;      default:        return 'METHOD:'.$this->method.$this->nl;        break;    }  }/** * set calendar property method * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-13 * @param string $method * @return void */  function setMethod( $method ) {    $this->method = $method;  }/*********************************************************************************//** * Property Name: PRODID * *  The identifier is RECOMMENDED to be the identical syntax to the * [RFC 822] addr-spec. A good method to assure uniqueness is to put the * domain name or a domain literal IP address of the host on which.. . *//** * creates formatted output for calendar property prodid * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.9.7 - 2006-11-20 * @return string */  function createProdid() {    if( !isset( $this->prodid ))      $this->_makeProdid();    switch( $this->format ) {      case 'xcal':        return ' prodid="'.$this->prodid.'"'.$this->nl;        break;      default:        return 'PRODID:'.$this->prodid.$this->nl;        break;    }  }/** * make default value for calendar prodid * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-10 * @return void */  function _makeProdid() {    $this->prodid  = '-//'.$this->unique_id.'//NONSGML '.ICALCREATOR_VERSION.'//'.strtoupper( $this->language );  }/** * Conformance: The property MUST be specified once in an iCalendar object. * Description: The vendor of the implementation SHOULD assure that this * is a globally unique identifier; using some technique such as an FPI * value, as defined in [ISO 9070]. *//** * make default unique_id for calendar prodid * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-10 * @return void */  function _makeUnique_id() {    $this->unique_id  = gethostbyname( $_SERVER['SERVER_NAME'] );  }/*********************************************************************************//** * Property Name: VERSION * * Description: A value of "2.0" corresponds to this memo. *//** * creates formatted output for calendar property version * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.9.7 - 2006-11-20 * @return string */  function createVersion() {    if( !isset( $this->version ))      $this->_makeVersion();    switch( $this->format ) {      case 'xcal':        return ' version="'.$this->version.'"'.$this->nl;        break;      default:        return 'VERSION:'.$this->version.$this->nl;        break;    }  }/** * set default calendar version * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-10 * @return void */  function _makeVersion() {    $this->version = '2.0';  }/** * set calendar version * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 0.3.0 - 2006-08-10 * @param string version * @return void */  function setVersion( $version ) {    $this->version = $version;  }/*********************************************************************************//** * Property Name: x-prop *//** * creates formatted output for calendar property x-prop, iCal format only * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.3.2 - 2007-11-25 * @return string */  function createXprop() {    if( 'xcal' == $this->format )      return false;    if( 0 >= count( $this->xprop ))      return;    $xprop = null;    $toolbox = new calendarComponent();    $toolbox->setConfig( 'language', $this->getConfig( 'language' ));    $toolbox->setConfig( 'nl',       $this->getConfig( 'nl' ));    $toolbox->_createFormat(         $this->getConfig( 'format' ));    foreach( $this->xprop as $label => $xpropPart ) {      $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));      if( is_array( $xpropPart['value'] )) {        foreach( $xpropPart['value'] as $pix => $theXpart )          $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );        $xpropPart['value']  = implode( ',', $xpropPart['value'] );      }      else        $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );      $xprop   .= $toolbox->_createElement( strtoupper( $label ), $attributes, $xpropPart['value'] );    }    return $xprop;  }/** * set calendar property x-prop * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.0.7 - 2007-06-21 * @param string $label * @param string $value * @param array $params optional * @return void */  function setXprop( $label, $value, $params=FALSE ) {    if( empty( $label ) || empty( $value ))      return;    $xprop = array( 'value' => $value );    $toolbox = new calendarComponent();    $xprop['params'] = $toolbox->_setParams( $params );    $this->xprop[$label] = $xprop;  }/*********************************************************************************//** * delete calendar property value * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.15 - 2007-10-29 * @param string $propName * @param int @propix, optional, if specific property is wanted in case of multiply occurences * @return bool, if successfull delete */  function deleteProperty( $propName, $propix=FALSE ) {    $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';    if( !$propix )      $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;    $this->propdelix[$propName] = --$propix;    $return = FALSE;    switch( $propName ) {      case 'CALSCALE':        $this->calscale = null;        $return = TRUE;        break;

⌨️ 快捷键说明

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