Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60600085
FlexElink.inc.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 1, 09:33
Size
3 KB
Mime Type
text/x-c++
Expires
Fri, May 3, 09:33 (2 d)
Engine
blob
Format
Raw Data
Handle
17381643
Attached To
R3600 invenio-infoscience
FlexElink.inc.php
View Options
<?
## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio 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
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
//Main class
include
(
RECORD_SEP
);
include
(
VARIABLE_EXT
);
include
(
PROCESSOR
);
class
CreateOAIMARCXMLFactory
{
function
CreateOAIMARCXMLFactory
()
{
$this
->
error
=
""
;
}
function
error
()
{
return
$this
->
error
;
}
function
&
createSeparator
(
$ifile
=
""
)
{
$sep
=
new
XMLSimpleRecSeparator
();
$error
=
$sep
->
setIFile
(
$ifile
);
if
(
$error
)
{
$this
->
error
=
$error
;
return
""
;
}
$sep
->
setTag
(
"record"
);
return
$sep
;
}
function
&
createExtractor
()
{
$ext
=
new
OAIVarExtractor
();
return
$ext
;
}
}
class
FlexElink
{
function
FlexElink
()
{
}
function
initialise
(
$itype
,
$ifile
=
""
)
{
$this
->
itype
=
trim
(
strtoupper
(
$itype
));
if
(
$itype
==
"OAIMARC"
)
$this
->
factory
=
new
CreateOAIMARCXMLFactory
();
else
return
"Not suported input type: $itype"
;
$this
->
separator
=&
$this
->
factory
->
createSeparator
(
$ifile
);
if
(!
$this
->
separator
)
return
"Error while creating the Record Separator: "
.
$this
->
factory
->
error
();
$this
->
extractor
=&
$this
->
factory
->
createExtractor
();
if
(!
$this
->
extractor
)
return
"Error while creating the Variable Extractor: "
.
$this
->
factory
->
error
();
$this
->
processor
=
new
Processor
();
return
""
;
}
function
getRecordResult
(
$otypes
,
$debug
=
0
)
{
$record
=
$this
->
clean
(
$this
->
separator
->
getRecord
());
//No more records
if
(
$record
==
""
)
return
array
(-
1
,
""
);
//More records
set_time_limit
(
TIMELIMIT
);
$vars
=
$this
->
extractor
->
getVars
(
"DEFAULT"
,
$record
);
if
(
$vars
==
null
)
return
array
(
0
,
$this
->
extractor
->
getError
());
if
(
$debug
)
$vars
->
debug
();
$result
=
""
;
foreach
(
$otypes
as
$otype
)
{
if
(
trim
(
$otype
)==
""
)
continue
;
list
(
$ok
,
$msg
)=
$this
->
processor
->
getOutput
(
$vars
,
$otype
,
$record
);
if
(
$ok
)
$result
.=
$msg
;
else
return
array
(
0
,
"Error processing record with otype '$otype':"
.
$msg
);
}
return
array
(
1
,
$result
);
}
function
getResult
(
$otype
,
$itype
,
$ifile
=
""
)
{
}
function
clean
(
$text
)
{
$text
=
str_replace
(
"
\0
16"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
17"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
18"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
19"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
20"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
21"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
22"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
23"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
24"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
25"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
26"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
27"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
28"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
29"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
30"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
31"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
32"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
33"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
34"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
35"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
36"
,
""
,
$text
);
$text
=
str_replace
(
"
\0
37"
,
""
,
$text
);
return
$text
;
}
}
?>
Event Timeline
Log In to Comment