mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
use directly MOBIClass
This commit is contained in:
parent
c70bfefc68
commit
fb9df0c269
47 changed files with 309 additions and 1551 deletions
96
inc/3rdparty/libraries/MOBIClass/Record.php
vendored
Normal file
96
inc/3rdparty/libraries/MOBIClass/Record.php
vendored
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
/**
|
||||
* A Record of a PDB file
|
||||
*
|
||||
* @author Sander
|
||||
*/
|
||||
class Record extends FileObject {
|
||||
/**
|
||||
* Data in the record
|
||||
* @var string
|
||||
*/
|
||||
private $data;
|
||||
/**
|
||||
* Length of the record
|
||||
* @var int
|
||||
*/
|
||||
private $length;
|
||||
|
||||
/**
|
||||
* Create a record
|
||||
* @param string $data Data contained in the record
|
||||
* @param int $length Length of the record (if set to -1,
|
||||
* the length of $data will be taken)
|
||||
*/
|
||||
public function __construct($data = "", $length = -1){
|
||||
$this->data = $data;
|
||||
if($length >= 0){
|
||||
$this->length = $length;
|
||||
}else{
|
||||
$this->length = strlen($data);
|
||||
}
|
||||
}
|
||||
|
||||
public function compress($compression_method){
|
||||
switch($compression_method){
|
||||
case NO_COMPRESSION:
|
||||
//Finished!
|
||||
break;
|
||||
case PALMDOC_COMPRESSION:
|
||||
throw new Exception("Not implemented yet");
|
||||
break;
|
||||
case HUFF:
|
||||
throw new Exception("Not implemented yet");
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid argument");
|
||||
}
|
||||
}
|
||||
|
||||
public function getByteLength(){
|
||||
return $this->getLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of the record
|
||||
* @return int Length of the data
|
||||
*/
|
||||
public function getLength(){
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data contained in the record
|
||||
* @return string Data contained in the record
|
||||
*/
|
||||
public function get(){
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data contained in the record
|
||||
* @param string $value Data contained in the record
|
||||
*/
|
||||
public function set($value){
|
||||
$this->data = $value;
|
||||
}
|
||||
|
||||
public function serialize(){
|
||||
return $this->data;
|
||||
}
|
||||
public function unserialize($data){
|
||||
__construct($data);
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
$toShow = $this->data;
|
||||
if(strlen($this->data) > 103){
|
||||
$toShow = substr($this->data, 0, 100)."...";
|
||||
}
|
||||
$out = "Record: {\n";
|
||||
$out .= "\t".htmlspecialchars($toShow)."\n";
|
||||
$out .= "}";
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue