ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilStyleReplaceResponsiveLogoObjective Class Reference
+ Inheritance diagram for ilStyleReplaceResponsiveLogoObjective:
+ Collaboration diagram for ilStyleReplaceResponsiveLogoObjective:

Public Member Functions

 __construct ()
 
 getHash ()
 @inheritDoc More...
 
 getLabel ()
 @inheritDoc More...
 
 isNotable ()
 @inheritDoc More...
 
 getPreconditions (Environment $environment)
 @inheritDoc More...
 
 achieve (Environment $environment)
 @inheritDoc More...
 
 getHash ()
 Get a hash for this objective. More...
 
 getLabel ()
 Get a label that describes this objective. More...
 
 isNotable ()
 Get to know if this is an interesting objective for a human. More...
 
 getPreconditions (Environment $environment)
 Objectives might depend on other objectives. More...
 
 achieve (Environment $environment)
 Objectives can be achieved. More...
 

Protected Member Functions

 maybeReplaceResponsiveIcon (string $skin_path)
 Replaces the responsive header-icon with the common header-icon, if the common icon is different from the ilias icon but the responsive icon is not. More...
 
 getFileHash (string $absolute_file_path)
 Returns the sha1-sum of the given file if it exists. More...
 

Protected Attributes

const RESPONSIVE_LOGO_PATH = '/images/HeaderIconResponsive.svg'
 
const COMMON_LOGO_PATH = '/images/HeaderIcon.svg'
 
 $delos_responsive_logo_hash
 
 $delos_common_logo_hash
 
 $delos_path
 
 $ilias_path
 

Detailed Description

Author
Thibeau Fuhrer thibe.nosp@m.au@s.nosp@m.r.sol.nosp@m.utio.nosp@m.ns @noinspection AutoloadingIssuesInspection

Definition at line 12 of file class.ilStyleReplaceResponsiveLogoObjective.php.

Constructor & Destructor Documentation

◆ __construct()

ilStyleReplaceResponsiveLogoObjective::__construct ( )

Definition at line 34 of file class.ilStyleReplaceResponsiveLogoObjective.php.

35 {
36 // determine ilias and delos-skin paths.
37 $this->ilias_path = dirname(__FILE__, 5);
38 $this->delos_path = "$this->ilias_path/templates/default/";
39
40 // calculate original logo hashes.
41 $this->delos_responsive_logo_hash = $this->getFileHash($this->delos_path . self::RESPONSIVE_LOGO_PATH);
42 $this->delos_common_logo_hash = $this->getFileHash($this->delos_path . self::COMMON_LOGO_PATH);
43 }
getFileHash(string $absolute_file_path)
Returns the sha1-sum of the given file if it exists.

References getFileHash().

+ Here is the call graph for this function:

Member Function Documentation

◆ achieve()

ilStyleReplaceResponsiveLogoObjective::achieve ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 80 of file class.ilStyleReplaceResponsiveLogoObjective.php.

81 {
82 // abort if the header-icons of the delos skin could not be located.
83 if (null === $this->delos_common_logo_hash || null === $this->delos_responsive_logo_hash) {
84 return $environment;
85 }
86
87 $skin_directory = "$this->ilias_path/Customizing/global/skin/";
88
89 // nothing to do if no custom skins were installed/created.
90 if (!file_exists($skin_directory) || !is_dir($skin_directory)) {
91 return $environment;
92 }
93
94 foreach (new DirectoryIterator($skin_directory) as $skin_name) {
95 if ('.' === $skin_name || '..' === $skin_name) {
96 continue;
97 }
98
99 $this->maybeReplaceResponsiveIcon($skin_directory . $skin_name);
100 }
101
102 return $environment;
103 }
maybeReplaceResponsiveIcon(string $skin_path)
Replaces the responsive header-icon with the common header-icon, if the common icon is different from...
An environment holds resources to be used in the setup process.
Definition: Environment.php:12

References maybeReplaceResponsiveIcon().

+ Here is the call graph for this function:

◆ getFileHash()

ilStyleReplaceResponsiveLogoObjective::getFileHash ( string  $absolute_file_path)
protected

Returns the sha1-sum of the given file if it exists.

Definition at line 124 of file class.ilStyleReplaceResponsiveLogoObjective.php.

124 : ?string
125 {
126 if (!file_exists($absolute_file_path)) {
127 return null;
128 }
129
130 if (false !== ($hash = sha1_file($absolute_file_path))) {
131 return $hash;
132 }
133
134 return null;
135 }

Referenced by __construct(), and maybeReplaceResponsiveIcon().

+ Here is the caller graph for this function:

◆ getHash()

ilStyleReplaceResponsiveLogoObjective::getHash ( )

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 48 of file class.ilStyleReplaceResponsiveLogoObjective.php.

48 : string
49 {
50 return hash("sha256", self::class);
51 }

◆ getLabel()

ilStyleReplaceResponsiveLogoObjective::getLabel ( )

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 56 of file class.ilStyleReplaceResponsiveLogoObjective.php.

56 : string
57 {
58 return 'Replacing responsive logos where necessary.';
59 }

◆ getPreconditions()

ilStyleReplaceResponsiveLogoObjective::getPreconditions ( Environment  $environment)

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 72 of file class.ilStyleReplaceResponsiveLogoObjective.php.

72 : array
73 {
74 return [];
75 }

◆ isNotable()

ilStyleReplaceResponsiveLogoObjective::isNotable ( )

@inheritDoc

Implements ILIAS\Setup\Objective.

Definition at line 64 of file class.ilStyleReplaceResponsiveLogoObjective.php.

64 : bool
65 {
66 return true;
67 }

◆ maybeReplaceResponsiveIcon()

ilStyleReplaceResponsiveLogoObjective::maybeReplaceResponsiveIcon ( string  $skin_path)
protected

Replaces the responsive header-icon with the common header-icon, if the common icon is different from the ilias icon but the responsive icon is not.

Definition at line 109 of file class.ilStyleReplaceResponsiveLogoObjective.php.

109 : void
110 {
111 $responsive_logo = $skin_path . self::RESPONSIVE_LOGO_PATH;
112 $common_logo = $skin_path . self::COMMON_LOGO_PATH;
113
114 if ($this->getFileHash($common_logo) !== $this->delos_common_logo_hash &&
115 $this->getFileHash($responsive_logo) === $this->delos_responsive_logo_hash
116 ) {
117 copy($common_logo, $responsive_logo);
118 }
119 }

References COMMON_LOGO_PATH, getFileHash(), and RESPONSIVE_LOGO_PATH.

Referenced by achieve().

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

Field Documentation

◆ $delos_common_logo_hash

ilStyleReplaceResponsiveLogoObjective::$delos_common_logo_hash
protected

◆ $delos_path

ilStyleReplaceResponsiveLogoObjective::$delos_path
protected

◆ $delos_responsive_logo_hash

ilStyleReplaceResponsiveLogoObjective::$delos_responsive_logo_hash
protected

◆ $ilias_path

ilStyleReplaceResponsiveLogoObjective::$ilias_path
protected

◆ COMMON_LOGO_PATH

const ilStyleReplaceResponsiveLogoObjective::COMMON_LOGO_PATH = '/images/HeaderIcon.svg'
protected

◆ RESPONSIVE_LOGO_PATH

const ilStyleReplaceResponsiveLogoObjective::RESPONSIVE_LOGO_PATH = '/images/HeaderIconResponsive.svg'
protected

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