2 namespace TYPO3\CMS\Rtehtmlarea\Extension;
45 'showmicrodata' =>
'ShowMicrodata'
57 'properties' => array()
60 if (is_array($this->configuration[
'thisConfig'][
'schema.']) && is_array($this->configuration[
'thisConfig'][
'schema.'][
'sources.'])) {
61 foreach ($this->configuration[
'thisConfig'][
'schema.'][
'sources.'] as $source) {
62 $fileName = trim($source);
65 if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) {
66 $fileName =
'EXT:' . $this->extensionKey .
'/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf';
75 uasort($schema[
'types'], array($this,
'compareLabels'));
76 uasort($schema[
'properties'], array($this,
'compareLabels'));
79 $noSchema = $languageService->sL(
'LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type');
80 $noProperty = $languageService->sL(
'LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property');
81 array_unshift($schema[
'types'], array(
'name' =>
'none',
'label' => $noSchema));
82 array_unshift($schema[
'properties'], array(
'name' =>
'none',
'label' => $noProperty));
84 return 'RTEarea[editornumber].schemaUrl = "' . $this->
writeTemporaryFile(
'schema_' . $this->configuration[
'language'],
'js', json_encode($schema)) .
'";';
96 return strcoll($a[
'label'], $b[
'label']);
109 $properties = array();
111 $document = new \DOMDocument();
112 $document->loadXML($string);
115 $items = $document->getElementsByTagName(
'Description');
116 foreach ($items as $item) {
117 $name = $item->getAttribute(
'rdf:about');
118 $type = $item->getElementsByTagName(
'type');
119 if ($name && $type->length) {
120 $type = $type->item(0)->getAttribute(
'rdf:resource');
122 $resource[
'name'] = $name;
123 $labels = $item->getElementsByTagName(
'label');
124 if ($labels->length) {
125 foreach ($labels as $label) {
126 $language = $label->getAttribute(
'xml:lang');
127 if ($language === $this->language) {
128 $resource[
'label'] = $label->nodeValue;
129 }
elseif ($language ===
'en') {
130 $defaultLabel = $label->nodeValue;
133 if (!$resource[
'label']) {
134 $resource[
'label'] = $defaultLabel;
137 $comments = $item->getElementsByTagName(
'comment');
138 if ($comments->length) {
139 foreach ($comments as $comment) {
140 $language = $comment->getAttribute(
'xml:lang');
141 if ($language === $this->language) {
142 $resource[
'comment'] = $comment->nodeValue;
143 }
elseif ($language ===
'en') {
144 $defaultComment = $comment->nodeValue;
147 if (!$resource[
'comment']) {
148 $resource[
'comment'] = $defaultComment;
152 case 'http://www.w3.org/2000/01/rdf-schema#Class':
153 $subClassOfs = $item->getElementsByTagName(
'subClassOf');
154 if ($subClassOfs->length) {
155 foreach ($subClassOfs as $subClassOf) {
156 $resource[
'subClassOf'] = $subClassOf->getAttribute(
'rdf:resource');
160 if (!in_array($resource[
'name'], $types)) {
161 $schema[
'types'][] = $resource;
162 $types[] = $resource[
'name'];
165 case 'http://www.w3.org/1999/02/22-rdf-syntax-ns#Property':
168 $pos = strrpos($resource[
'name'],
'/');
170 $resource[
'name'] = substr($resource[
'name'], $pos + 1);
172 $domains = $item->getElementsByTagName(
'domain');
173 if ($domains->length) {
174 foreach ($domains as $domain) {
175 $resource[
'domain'] = $domain->getAttribute(
'rdf:resource');
178 $ranges = $item->getElementsByTagName(
'range');
179 if ($ranges->length) {
180 foreach ($ranges as $range) {
181 $resource[
'range'] = $range->getAttribute(
'rdf:resource');
185 if (!in_array($resource[
'name'], $properties)) {
186 $schema[
'properties'][] = $resource;
187 $properties[] = $resource[
'name'];