Documentation is available at classes_file.php
- <?php
- class b_resource extends b_object {
- //base resource definition
- var $path;
- var $resource_type;
- var $create_date;
- var $name;
- var $description;
- function b_resource( $constructID, $typeName, $objectInfo = NULL ) {
- $this->type =& $GLOBALS['core']->get_object_type( $typeName );
- if( !$object_info && !$object_info =& $this->type->object_info[ $constructID ] ) {
- global $db;
- if( $object_info = $db->get_results( "SELECT * FROM ".$this->type->type_table_name." WHERE id = '".$constructID."' || path = '".format_path($constructID)."'", ARRAY_A ) ) {
- $object_info = reset($object_info);
- }
- }
- parent::b_object( $object_info['id'], $typeName, $object_info );
- $this->create_date = toPhpDate( $this->create_date );
- $this->resource_type = $this->set_resource_type();
- }
- function verify_set( $post ) {
- //windows file handling
- if( $post['path'] ) { $post['path'] = format_path( $post['path'] ); }
- //date handling
- if( !$post['create_date'] && isset( $post['create_date'] ) ) {
- if( $post['create_date'] ) {
- $post['create_date'] = toDbDate( $post['create_date'] );
- } else {
- //if no date specified
- //use the file's last modify date or the current date
- if( !$time = filemtime( $this->path ) ) {
- $time = 'today';
- }
- $post['create_date'] = toDbDate( $time );
- }
- }
- //name handling
- if( $post['path'] && !$post['name'] ) {
- $post['name'] = basename($post['path'],"\/");
- }
- if( $post['path'] && !file_exists( $post['path'] ) ) {
- $returnArray['path'] = 'file or directory does not exist';
- }
- if( !count($returnArray) ) {
- parent::verify_set( $post );
- } else {
- $GLOBALS['errorArray'] = $returnArray;
- //$this->set_object( $post );
- }
- }
- function set_resource_type() {
- //NOTE: this is currently set up to determine where the resource is located, not so much the type of the resource
- if( !$type ) {
- if( stristr( $this->path, 'http://' ) ) { return 'href'; }
- else if( stristr( $this->path, 'ftp://' ) ) { return 'ftp'; }
- else { return 'file'; }
- } else {
- return $type;
- }
- }
- function validate() {
- if( $this->resource_type == 'file' ) {
- return file_exists( $this->path );
- } else {
- return true;
- }
- }
- }
- ?>
Documentation generated on Tue, 24 May 2005 03:57:04 -0400 by phpDocumentor 1.3.0RC3