-
Notifications
You must be signed in to change notification settings - Fork 16
/
XBRL-IFRS-Package.php
118 lines (106 loc) · 3.91 KB
/
XBRL-IFRS-Package.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
/**
* XBRL IFRS Taxonomy Package handler
*
* @author Bill Seddon
* @version 0.9
* @Copyright (C) 2018 Lyquidity Solutions Limited
*
* This program 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 3 of the License, or
* (at your option) any later version.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Implements functions to read an IFRS taxonomy package
*/
class XBRL_IFRS_Package extends XBRL_TaxonomyPackage
{
/**
* Notes about using this package instance
* @var string
*/
const notes = <<<EOT
Uses the path of the entry point in the taxonomyPackage.xml file to determine the path to use in the cache.
This should be the same as the value used in the schemaRef element in the instance document.
The 'identifier' value in the taxonomyPackage.xml file appears to be the namespace of the taxonomy.\n\n
The static array '\$defaultEntryPoints' will need to be updated each time there is a new taxonomy release
to add a new default entry point.\n\n
EOT;
/**
* This will need to be updated when a new taxonomy is released
* @var array Indexed by publication date
*/
private static $defaultEntryPoints = array(
'2016-03-31' => 'http://xbrl.ifrs.org/taxonomy/2016-03-31/combined_doc_entry_point_2016-03-31.xsd',
'2017-03-09' => 'http://xbrl.ifrs.org/taxonomy/2017-03-09/combined_doc_entry_point_2017-03-09.xsd',
'2018-03-16' => 'http://xbrl.ifrs.org/taxonomy/2018-03-16/combined_doc_entry_point_2018-03-16.xsd'
);
/**
* Returns true if the zip file represents a package that meets the taxonomy package specification
* {@inheritDoc}
* @see XBRL_Package::isPackage()
*/
public function isPackage()
{
if ( ! parent::isPackage() ) return false;
// If it is a package then is an IFRS taxonomy package?
// An IFRS package is characterised by having one or more of the
// package entry points be the entry points in the XBRL_IFRS entry point list
// and no instance document.
// Check the entry points first because they are already in an array.
foreach ( $this->getSchemaEntryPoints() as $entryPoint )
{
if ( XBRL::startsWith( $entryPoint, "http://xbrl.ifrs.org/" ) ) return true;
}
return false;
}
/**
* Workout which file is the schema file
* @return void
* @throws "tpe:schemaFileNotFound"
*/
protected function determineSchemaFile()
{
if ( ! is_null( $this->schemaFile ) ) return;
$schemaFilesList = $this->getSchemaEntryPoints();
if ( count( $schemaFilesList ) == 0 )
{
throw XBRL_TaxonomyPackageException::withError( "tpe:schemaFileNotFound", "The package does not contain a schema (.xsd) file" );
}
foreach ( $schemaFilesList as $schemaFile )
{
$actualUri = $this->getActualUri( $schemaFile );
$content = $this->getFile( $actualUri );
if ( $content )
{
$schemaNamespace = $this->getTargetNamespace( $schemaFile, $content );
$this->setUrlMap( $schemaNamespace, $schemaFile );
if ( isset( XBRL_IFRS_Package::$defaultEntryPoints[ $this->publicationDate ] ) &&
XBRL_IFRS_Package::$defaultEntryPoints[ $this->publicationDate ] == $schemaFile )
{
$this->schemaNamespace = $schemaNamespace;
$this->schemaFile = $schemaFile;
}
}
}
}
/**
* Returns the name of the XBRL class that supports IFRS pckage contents
* {@inheritDoc}
* @see XBRL_Package::getXBRLClassname()
*/
public function getXBRLClassname()
{
return "XBRL_IFRS";
}
}