<?php
/**
* Entier Studio
*
* LICENSE
*
* Copyright 2006 Entier Studio team.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @package entier.framework
* @copyright Copyright (c) 2006 Entier Studio team. All rights reserved.
* @version $Id: text.datasource.php 81 2008-01-17 23:08:21Z yannromefort $
*/
//-----------------------------------------------------------------------------
// namespace
if (!defined("DefTEXTDataSource")) {
//-------------------------------------------------------------------------
// Define
define("DefTEXTDataSource", "1");
//-------------------------------------------------------------------------
// Includes
@require_once (FRAMEWORK_DIR . "datasource.php");
//-------------------------------------------------------------------------
// Class TEXTDataSource
class TEXTDataSource extends DataSource {
//---------------------------------------------------------------------
// Attributes
/**
* Parser error code
* @var integer
*/
var $m_ErrorCode = 0;
//---------------------------------------------------------------------
// Constructor
/**
* Data source constructor
* @param string host
* @param string port
* @param string user
* @param string pass
* @param string base
*/
function TEXTDataSource($hostName = "", $hostPort = 0, $userName = "", $passWord = "", $dataBase = "") {
$this->m_protocol = "text";
$this->m_hostName = $hostName;
$this->m_hostPort = $hostPort;
$this->m_userName = $userName;
$this->m_passWord = $passWord;
$this->m_dataBase = $dataBase;
}
//---------------------------------------------------------------------
// Properties
/**
*
* overrided DataSource property
*
* @return object
*
* @see
*/
function getDataHandler() {
//
return ($this);
}
/**
*
* overrided DataSource property
*
* @return string
*/
function errorString() {
//
switch ($this->m_ErrorCode) {
case 1:
//
return ("");
//
break;
default:
//
return ("");
//
break;
}
//
return ("");
}
/**
*
* overrided DataSource property
*
* @return integer
*/
function errorNumber() {
//
return ($this->m_ErrorCode);
}
//---------------------------------------------------------------------
// Methods
//
//DataSource interface
//
/**
*
* Open a data source
* @param string
* @return boolean
*
*/
function openConnection() {
//
if ($this->clearConnection() == false) return (false);
//
if (!($this->m_resource = @fopen($this->m_hostName, "r"))) {
//
$this->m_ErrorCode = 1;
//
return (false);
}
//
return (true);
}
/**
*
* Close a data source
* @return boolean Return flag
*
*/
function closeConnection() {
//
if ($this->isConnectionOpen() == false) return (false);
//
if (@fclose($this->m_resource)) {
//
$this->m_resource = false;
//
return (true);
}
//
return (false);
}
//
//TextReader interface
/**
*
* Tests for end-of-file on a file pointer
* @return boolean
*
*/
function EndOfText() {
//
return (@feof($this->m_resource));
}
/**
*
* File read in text mode ( fopen( "r") )
* @param integer
* @return boolean
*
*/
function ReadText($length) {
//
return (@fread($this->m_resource, $length));
}
};
// Class
//-------------------------------------------------------------------------
}
// namespace
//-----------------------------------------------------------------------------
?>