ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Repository\Provider\RepositoryOpenGraphExposer Class Reference
+ Inheritance diagram for ILIAS\Repository\Provider\RepositoryOpenGraphExposer:
+ Collaboration diagram for ILIAS\Repository\Provider\RepositoryOpenGraphExposer:

Public Member Functions

 __construct (\ILIAS\DI\Container $dic)
 
 isInterestedInContexts ()
 
 getContentModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\Layout\Provider\AbstractModificationProvider
 __construct (Container $dic)
 @inheritDoc More...
 
 getContentModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getLogoModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getResponsiveLogoModification (CalledContexts $screen_context_stack)
 
 getMainBarModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getMetaBarModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getBreadCrumbsModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getFooterModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getPageBuilderDecorator (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getTitleModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getShortTitleModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
 getViewTitleModification (CalledContexts $screen_context_stack)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getContentModification (CalledContexts $screen_context_stack)
 
 getLogoModification (CalledContexts $screen_context_stack)
 
 getResponsiveLogoModification (CalledContexts $screen_context_stack)
 
 getMainBarModification (CalledContexts $screen_context_stack)
 
 getMetaBarModification (CalledContexts $screen_context_stack)
 
 getBreadCrumbsModification (CalledContexts $screen_context_stack)
 
 getFooterModification (CalledContexts $screen_context_stack)
 
 getPageBuilderDecorator (CalledContexts $screen_context_stack)
 
 getTitleModification (CalledContexts $screen_context_stack)
 
 getShortTitleModification (CalledContexts $screen_context_stack)
 
 getViewTitleModification (CalledContexts $screen_context_stack)
 
 isInterestedInContexts ()
 

Protected Member Functions

 getObjectOfContext (ScreenContext $context)
 
 getDefaultImage ()
 
 getLanguageCodesFromLOM (int $object_id, string $object_type)
 
 ensureRepoContext (CalledContexts $screen_context_stack)
 
 getPresentationImage (\ilObject $object)
 
- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 

Private Member Functions

 exposeObjectOpenGraphMetaData (\ilObject $object)
 
 exposeDefaultOpenGraphMetaData ()
 

Private Attributes

LOMServices $lom_services
 
bool $fetch_tile_image = false
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\Layout\Provider\AbstractModificationProvider
ContextCollection $context_collection
 
DataFactory $data
 
ModificationFactory $factory
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::__construct ( \ILIAS\DI\Container  $dic)

Definition at line 44 of file RepositoryOpenGraphExposer.php.

45 {
46 $this->lom_services = $dic->learningObjectMetadata();
48 }
$dic
Definition: ltiresult.php:33
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $dic, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ ensureRepoContext()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::ensureRepoContext ( CalledContexts  $screen_context_stack)
protected

Definition at line 167 of file RepositoryOpenGraphExposer.php.

167 : CalledContexts
168 {
169 $collection = new ContextCollection(
170 $this->dic->globalScreen()->tool()->context()->availableContexts()
171 );
172 $collection = $collection->repository();
173
174 if (!$screen_context_stack->hasMatch($collection)) {
175 $screen_context_stack = $screen_context_stack->repository();
176 }
177 return $screen_context_stack;
178 }

References ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\hasMatch(), and ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\repository().

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getContentModification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exposeDefaultOpenGraphMetaData()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::exposeDefaultOpenGraphMetaData ( )
private

Definition at line 109 of file RepositoryOpenGraphExposer.php.

109 : void
110 {
111 $uri = $this->data->uri(ILIAS_HTTP_PATH);
112
113 $this->globalScreen()->layout()->meta()->addOpenGraphMetaDatum(
114 $this->data->openGraphMetadata()->website(
115 $uri,
116 $this->getDefaultImage(),
117 $this->dic->language()->txt('permission_denied'),
118 $uri->getHost(),
119 )
120 );
121 }

References ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen().

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getContentModification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ exposeObjectOpenGraphMetaData()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::exposeObjectOpenGraphMetaData ( \ilObject  $object)
private

Definition at line 78 of file RepositoryOpenGraphExposer.php.

78 : void
79 {
80 $object_translation = $object->getObjectProperties()->getPropertyTranslations();
81
82 $additional_locale_count = 0;
83 $additional_locales = [];
84
85 foreach ($this->getLanguageCodesFromLOM($object->getId(), $object->getType()) as $language_code) {
86 if ($language_code !== $object_translation->getDefaultLanguage()) {
87 $additional_locales[] = $language_code;
88 $additional_locale_count++;
89 }
90 }
91
92 $uri = $this->data->uri(\ilLink::_getStaticLink($object->getRefId(), $object->getType()));
93
94 $image = $this->getPresentationImage($object);
95
96 $this->globalScreen()->layout()->meta()->addOpenGraphMetaDatum(
97 $this->data->openGraphMetadata()->website(
98 $uri,
99 $image,
100 $object->getPresentationTitle(),
101 $uri->getHost(),
102 $object->getLongDescription() . ' ', // we add a space to ensure the description is not cut off
103 $object_translation->getDefaultLanguage(),
104 (1 < $additional_locale_count) ? array_slice($additional_locales, 1) : []
105 )
106 );
107 }

References ilLink\_getStaticLink(), ilObject\getId(), ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getLanguageCodesFromLOM(), ilObject\getLongDescription(), ilObject\getObjectProperties(), ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getPresentationImage(), ilObject\getPresentationTitle(), ilObject\getRefId(), ilObject\getType(), and ILIAS\GlobalScreen\Provider\AbstractProvider\globalScreen().

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getContentModification().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getContentModification()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::getContentModification ( CalledContexts  $screen_context_stack)

@inheritDoc

Reimplemented from ILIAS\GlobalScreen\Scope\Layout\Provider\AbstractModificationProvider.

Definition at line 60 of file RepositoryOpenGraphExposer.php.

60 : ?ContentModification
61 {
62 $current_context = $this->ensureRepoContext($screen_context_stack)->current();
63 $ref_id = $current_context->getReferenceId()->toInt();
64
65 if (
66 $ref_id > 0
67 && $this->dic->access()->checkAccess('visible', '', $ref_id)
68 && null !== ($object = $this->getObjectOfContext($current_context))
69 ) {
70 $this->exposeObjectOpenGraphMetaData($object);
71 } else {
73 }
74
75 return null;
76 }
$ref_id
Definition: ltiauth.php:66

References $ref_id, ILIAS\Repository\Provider\RepositoryOpenGraphExposer\ensureRepoContext(), ILIAS\Repository\Provider\RepositoryOpenGraphExposer\exposeDefaultOpenGraphMetaData(), and ILIAS\Repository\Provider\RepositoryOpenGraphExposer\exposeObjectOpenGraphMetaData().

+ Here is the call graph for this function:

◆ getDefaultImage()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::getDefaultImage ( )
protected

Definition at line 138 of file RepositoryOpenGraphExposer.php.

138 : OGImage
139 {
140 $image_path_resolver = new \ilImagePathResolver();
141
142 return $this->data->openGraphMetadata()->image(
143 $this->data->uri(
144 ILIAS_HTTP_PATH . ltrim(
145 $image_path_resolver->resolveImagePath(
146 'logo/Sharing.jpg'
147 ),
148 '.'
149 )
150 ),
151 'image/jpg'
152 );
153 }

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getPresentationImage().

+ Here is the caller graph for this function:

◆ getLanguageCodesFromLOM()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::getLanguageCodesFromLOM ( int  $object_id,
string  $object_type 
)
protected
Returns
string[]

Definition at line 158 of file RepositoryOpenGraphExposer.php.

158 : \Generator
159 {
160 $languages_path = $this->lom_services->paths()->languages();
161 $reader = $this->lom_services->read($object_id, 0, $object_type, $languages_path);
162 foreach ($reader->allData($languages_path) as $lang_data) {
163 yield $lang_data->value();
164 }
165 }

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\exposeObjectOpenGraphMetaData().

+ Here is the caller graph for this function:

◆ getObjectOfContext()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::getObjectOfContext ( ScreenContext  $context)
protected

Definition at line 123 of file RepositoryOpenGraphExposer.php.

123 : ?\ilObject
124 {
125 if (!$context->hasReferenceId()) {
126 return null;
127 }
128
129 try {
130 $current_object = \ilObjectFactory::getInstanceByRefId($context->getReferenceId()->toInt());
132 $current_object = null;
133 } finally {
134 return $current_object;
135 }
136 }
Class ilDatabaseException.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
Class ilObject Basic functions for all objects.
$context
Definition: webdav.php:31

References $context, and ilObjectFactory\getInstanceByRefId().

+ Here is the call graph for this function:

◆ getPresentationImage()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::getPresentationImage ( \ilObject  $object)
protected

Definition at line 180 of file RepositoryOpenGraphExposer.php.

180 : OGImage
181 {
182 $image_factory = $this->dic->ui()->factory()->image();
183 $image = $this->getDefaultImage();
184 if (!$this->fetch_tile_image) {
185 return $image;
186 }
187 try {
188 // Use the tile image if available
189 $tile_image = $object->getObjectProperties()->getPropertyTileImage()->getTileImage();
190 if ($tile_image !== null && $tile_image->getRid() !== null) {
191 $uri_string = $tile_image->getImage($image_factory)->getAdditionalHighResSources()['960']
192 ?? $tile_image->getImage($image_factory)->getSource();
193
194 $image = $this->data->openGraphMetadata()->image(
195 $this->data->uri($uri_string),
196 'image/jpg'
197 );
198 }
199 } catch (\Throwable $e) {
200 }
201 return $image;
202 }

References Vendor\Package\$e, ILIAS\Repository\Provider\RepositoryOpenGraphExposer\getDefaultImage(), and ilObject\getObjectProperties().

Referenced by ILIAS\Repository\Provider\RepositoryOpenGraphExposer\exposeObjectOpenGraphMetaData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isInterestedInContexts()

ILIAS\Repository\Provider\RepositoryOpenGraphExposer::isInterestedInContexts ( )
Returns
ContextCollection

Implements ILIAS\GlobalScreen\ScreenContext\ScreenContextAwareProvider.

Definition at line 50 of file RepositoryOpenGraphExposer.php.

50 : ContextCollection
51 {
52 // the exposer is interested in any context, BUT the repository context
53 // will be handled differently.
54 return $this->context_collection
55 ->internal()
56 ->external()
57 ->repository();
58 }

References ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection\external().

+ Here is the call graph for this function:

Field Documentation

◆ $fetch_tile_image

bool ILIAS\Repository\Provider\RepositoryOpenGraphExposer::$fetch_tile_image = false
private

Definition at line 41 of file RepositoryOpenGraphExposer.php.

◆ $lom_services

LOMServices ILIAS\Repository\Provider\RepositoryOpenGraphExposer::$lom_services
private

Definition at line 39 of file RepositoryOpenGraphExposer.php.


The documentation for this class was generated from the following file: