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

📄 icalcreator.class.php

📁 完美的在线教育系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
      case 'METHOD':        $this->method   = null;        $return = TRUE;        break;      default:        if( $propName != 'X-PROP' ) {          if( !isset( $this->xprop[$propName] )) return FALSE;          unset( $this->xprop[$propName] );          $return = TRUE;        }        else {          if( count( $this->xprop ) <= $propix )  return FALSE;          $xpropno = 0;          foreach( $this->xprop as $xpropkey => $xpropvalue ) {            if( $propix == $xpropno ) {              unset( $this->xprop[$xpropkey] );              $return = TRUE;              break 2;            }            else              $xpropno++;          }        }    }    return $return;  }/** * get calendar property value/params * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.0.8 - 2007-07-07 * @param string $propName, optional * @param int @propix, optional, if specific property is wanted in case of multiply occurences * @param bool $inclParam=FALSE * @return mixed */  function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {    $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';    if( !$propix )      $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;    $this->propix[$propName] = --$propix;    switch( $propName ) {      case 'CALSCALE':        if( 0 < $propix ) return FALSE;        return ( !empty( $this->calscale )) ? $this->calscale : null;        break;      case 'METHOD':        if( 0 < $propix ) return FALSE;        return ( !empty( $this->method )) ? $this->method : null;        break;      case 'PRODID':        if( 0 < $propix ) return FALSE;        if( empty( $this->prodid ))          $this->_makeProdid();        return $this->prodid;        break;      case 'VERSION':        if( 0 < $propix ) return FALSE;        return ( !empty( $this->version )) ? $this->version : null;        break;      default:        if( $propName != 'X-PROP' ) {          if( !isset( $this->xprop[$propName] )) return FALSE;          return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )                                : array( $propName, $this->xprop[$propName]['value'] );        }        else {          if( count( $this->xprop ) <= $propix )  return FALSE;          $xpropno = 0;          foreach( $this->xprop as $xpropkey => $xpropvalue ) {            if( $propix == $xpropno )              return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )                                    : array( $xpropkey, $this->xprop[$xpropkey]['value'] );            else              $xpropno++;          }          return FALSE; // not found ??        }    }    return FALSE;  }/** * general vcalendar property setting * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.13 - 2007-10-23 * @param mixed $args variable number of function arguments, *                    first argument is ALWAYS component name, *                    second ALWAYS component value! * @return void */  function setProperty () {    $numargs    = func_num_args();    if( 1 >= $numargs )      return FALSE;    $arglist    = func_get_args();    if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))      return;    $arglist[0] = strtoupper( $arglist[0] );    for( $argix=$numargs; $argix < 3; $argix++ ) {      if( !isset( $arglist[$argix] ))        $arglist[$argix] = null;    }    switch( $arglist[0] ) {      case 'CALSCALE':        $this->setCalscale( $arglist[1] );        break;      case 'METHOD':        $this->setMethod( $arglist[1] );        break;      case 'VERSION':        $this->setVersion( $arglist[1] );        break;      default:        $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );        break;    }  }/*********************************************************************************//** * get vcalendar config values or * calendar components * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.13 - 2007-12-30 * @param string $config * @return value */  function getConfig( $config ) {    switch( strtoupper( $config )) {      case 'ALLOWEMPTY':        return $this->allowEmpty;        break;      case 'COMPSINFO':        unset( $this->compix );        $info = array();        foreach( $this->components as $cix => $component ) {          unset( $component->propix );          $info[$cix]['ordno'] = $cix + 1;          $info[$cix]['type']  = $component->objName;          $info[$cix]['uid']   = $component->getProperty( 'uid' );          $info[$cix]['props'] = $component->getConfig( 'propinfo' );          $info[$cix]['sub']   = $component->getConfig( 'compsinfo' );          unset( $component->propix );        }        return $info;        break;      case 'DELIMITER':        return $this->delimiter;        break;      case 'DIRECTORY':        if( empty( $this->directory ))          $this->directory = '.';        return $this->directory;        break;      case 'DIRFILE':        return $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$this->getConfig( 'filename' );        break;      case 'FILEINFO':        return array( $this->getConfig( 'directory' )                    , $this->getConfig( 'filename' )                    , $this->getConfig( 'filesize' ));        break;      case 'FILENAME':        if( empty( $this->filename )) {          if( 'xcal' == $this->format )            $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .          else            $this->filename = date( 'YmdHis' ).'.ics';        }        return $this->filename;        break;      case 'FILESIZE':        $size    = 0;        if( empty( $this->url )) {          $dirfile = $this->getConfig( 'dirfile' );          if( FALSE === ( $size = filesize( $dirfile )))            $size = 0;          clearstatcache();        }        return $size;        break;      case 'FORMAT':        return $this->format;        break;      case 'LANGUAGE':         /* get language for calendar component as defined in [RFC 1766] */        return $this->language;        break;      case 'NL':      case 'NEWLINECHAR':        return $this->nl;        break;      case 'UNIQUE_ID':        return $this->unique_id;        break;      case 'URL':        if( !empty( $this->url ))          return $this->url;        else          return FALSE;        break;    }  }/** * general vcalendar config setting * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.13 - 2007-12-30 * @param string $config * @param string $value * @return void */  function setConfig( $config, $value ) {    switch( strtoupper( $config )) {      case 'ALLOWEMPTY':        $this->allowEmpty = $value;        break;      case 'DELIMITER':        $this->delimiter = $value;        break;      case 'DIRECTORY':        $value   = trim( $value );        $nl      = $this->getConfig('delimiter');        if( $nl == substr( $value, ( 0 - strlen( $nl ))))          $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));        if( is_dir( $value )) {            /* local directory */          clearstatcache();          $this->directory = $value;          $this->url       = null;          return TRUE;        }        else          return FALSE;        break;      case 'FILENAME':        $value   = trim( $value );        if( !empty( $this->url )) {            /* remote directory+file - URL */          $this->filename = $value;          return TRUE;        }        $dirfile = $this->getConfig( 'directory' ).$this->getConfig( 'delimiter' ).$value;        if( file_exists( $dirfile )) {            /* local existing file */          if( is_readable( $dirfile ) || is_writable( $dirfile )) {            clearstatcache();            $this->filename = $value;            return TRUE;          }          else            return FALSE;        }        elseif( FALSE !== touch( $dirfile )) {            /* new local file created */          $this->filename = $value;          return TRUE;        }        else          return FALSE;        break;      case 'FORMAT':        $value   = trim( $value );        if( 'xcal' == strtolower( $value )) {          $this->format             = 'xcal';          $this->attributeDelimiter = $this->nl;          $this->valueInit          = null;        }        else {          $this->format             = null;          $this->attributeDelimiter = ';';          $this->valueInit          = ':';        }        break;      case 'LANGUAGE':         // set language for calendar component as defined in [RFC 1766]        $value   = trim( $value );        $this->language = $value;        break;      case 'NL':      case 'NEWLINECHAR':        $this->nl = $value;        break;      case 'UNIQUE_ID':        $value   = trim( $value );        $this->unique_id = $value;        break;      case 'URL':            /* remote file - URL */        $value     = trim( $value );        $value     = str_replace( 'HTTP://',   'http://', $value );        $value     = str_replace( 'WEBCAL://', 'http://', $value );        $value     = str_replace( 'webcal://', 'http://', $value );        $this->url = $value;        $this->directory = null;        $parts     = pathinfo( $value );        return $this->setConfig( 'filename',  $parts['basename'] );        break;    }  }/*********************************************************************************//** * validDate * * convert input parameters to (valid) iCalcreator date in array format (or FALSE) * if $utc=TRUE and $tz = utc offset ([[+/]-]HHmm) input (local) date array + UTC offset * returns ouput in UTC format date * * @author Kjell-Inge Gustafsson <ical@kigkonsult.se> * @since 2.2.2 - 2007-07-29 * @param mixed $year * @param mixed $month optional * @param int $day optional * @param int $hour optional * @param int $min optional * @param int $sec optional * @param mixed $tz optional * @param bool $utc optional * @return bool false / array $date */  function validDate( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $tz=FALSE, $utc=FALSE ) {    $input   = array();    $toolbox = new calendarComponent();    $parno   = null;    if( is_array( $year ) && isset( $year['timestamp'] )) {      $input        = $toolbox->_date_time_string( date( 'Y-m-d H:i:s', $year['timestamp'] ), 6 );      $input['tz']  = ( isset( $year['tz'] )) ? $year['tz'] : null;      $utc = ( TRUE === $month ) ? TRUE : FALSE;    }    elseif( is_array( $year ) && ( in_array( count( $year ), array( 3, 4, 6, 7 )))) {      if( isset( $year['tz'] ) || ( 4 == count( $year )) || ( 7 == count( $year )))        $parno = 7;      elseif( isset( $year['hour'] ) || isset( $year['min'] ) || isset( $year['sec'] ) ||            ( 6 == count( $year )))        $parno = 6;      else        $parno = 3;      $input = $toolbox->_date_time_array( $year, $parno );      $utc = ( TRUE === $month ) ? TRUE : FALSE;    }    elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18      $input = $toolbox->_date_time_string( $year );      $utc = ( TRUE === $month ) ? TRUE : FALSE;    }    elseif(( $year !== FALSE ) && ( $month !== FALSE ) && ( $day !== FALSE )) {      if(( 0 > (int) $year ) || (2100 < (int) $year ))        return FALSE;      $month = (int) $month;      if(( 1 > $month ) || ( 12 < $month ))        return FALSE;      $day   = (int) $day;      if(( 1 > $day ) || ( 31 < $day ))        return FALSE;

⌨️ 快捷键说明

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