ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStyleReplaceResponsiveLogoObjective Class Reference
+ Inheritance diagram for ilStyleReplaceResponsiveLogoObjective:
+ Collaboration diagram for ilStyleReplaceResponsiveLogoObjective:

Public Member Functions

 __construct ()
 
 getHash ()
 
 getLabel ()
 
 isNotable ()
 
 isApplicable (Environment $environment)
 Get to know whether the objective is applicable.Don't change the environment or cause changes on services in the environment. Just check if this objective needs to be achieved, either currently or at all. In case of doubt whether the objective is applicable or not return true. More...
 
 getPreconditions (Environment $environment)
 
 achieve (Environment $environment)
 

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
 
 $skins_path
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilStyleReplaceResponsiveLogoObjective::__construct ( )

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

References getFileHash().

39  {
40  // determine ilias and delos-skin paths.
41  $this->ilias_path = dirname(__FILE__, 5);
42  $this->delos_path = "$this->ilias_path/templates/default/";
43  $this->skins_path = "$this->ilias_path/Customizing/global/skin/";
44 
45  // calculate original logo hashes.
46  $this->delos_responsive_logo_hash = $this->getFileHash($this->delos_path . self::RESPONSIVE_LOGO_PATH);
47  $this->delos_common_logo_hash = $this->getFileHash($this->delos_path . self::COMMON_LOGO_PATH);
48  }
getFileHash(string $absolute_file_path)
Returns the sha1-sum of the given file if it exists.
+ Here is the call graph for this function:

Member Function Documentation

◆ achieve()

ilStyleReplaceResponsiveLogoObjective::achieve ( Environment  $environment)

Implements ILIAS\Setup\Objective.

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

References maybeReplaceResponsiveIcon().

94  : Environment
95  {
96  // abort if the header-icons of the delos skin could not be located.
97  if (null === $this->delos_common_logo_hash || null === $this->delos_responsive_logo_hash) {
98  return $environment;
99  }
100 
101  foreach (new DirectoryIterator($this->skins_path) as $skin_name) {
102  if ('.' === $skin_name || '..' === $skin_name) {
103  continue;
104  }
105 
106  $this->maybeReplaceResponsiveIcon($this->skins_path . $skin_name);
107  }
108 
109  return $environment;
110  }
An environment holds resources to be used in the setup process.
Definition: Environment.php:11
maybeReplaceResponsiveIcon(string $skin_path)
Replaces the responsive header-icon with the common header-icon, if the common icon is different from...
+ 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 131 of file class.ilStyleReplaceResponsiveLogoObjective.php.

Referenced by __construct(), and maybeReplaceResponsiveIcon().

131  : ?string
132  {
133  if (!file_exists($absolute_file_path)) {
134  return null;
135  }
136 
137  if (false !== ($hash = sha1_file($absolute_file_path))) {
138  return $hash;
139  }
140 
141  return null;
142  }
+ Here is the caller graph for this function:

◆ getHash()

ilStyleReplaceResponsiveLogoObjective::getHash ( )

Implements ILIAS\Setup\Objective.

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

53  : string
54  {
55  return hash("sha256", self::class);
56  }

◆ getLabel()

ilStyleReplaceResponsiveLogoObjective::getLabel ( )

Implements ILIAS\Setup\Objective.

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

61  : string
62  {
63  return 'Replacing responsive logos where necessary.';
64  }

◆ getPreconditions()

ilStyleReplaceResponsiveLogoObjective::getPreconditions ( Environment  $environment)

Implements ILIAS\Setup\Objective.

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

86  : array
87  {
88  return [];
89  }

◆ isApplicable()

ilStyleReplaceResponsiveLogoObjective::isApplicable ( Environment  $environment)

Get to know whether the objective is applicable.Don't change the environment or cause changes on services in the environment. Just check if this objective needs to be achieved, either currently or at all. In case of doubt whether the objective is applicable or not return true.

Implements ILIAS\Setup\Objective.

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

77  : bool
78  {
79  // nothing to do if no custom skins were installed/created.
80  return (file_exists($this->skins_path) && is_dir($this->skins_path));
81  }

◆ isNotable()

ilStyleReplaceResponsiveLogoObjective::isNotable ( )

Implements ILIAS\Setup\Objective.

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

69  : bool
70  {
71  return true;
72  }

◆ 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 116 of file class.ilStyleReplaceResponsiveLogoObjective.php.

References getFileHash().

Referenced by achieve().

116  : void
117  {
118  $responsive_logo = $skin_path . self::RESPONSIVE_LOGO_PATH;
119  $common_logo = $skin_path . self::COMMON_LOGO_PATH;
120 
121  if ($this->getFileHash($common_logo) !== $this->delos_common_logo_hash &&
122  $this->getFileHash($responsive_logo) === $this->delos_responsive_logo_hash
123  ) {
124  copy($common_logo, $responsive_logo);
125  }
126  }
getFileHash(string $absolute_file_path)
Returns the sha1-sum of the given file if it exists.
+ 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

◆ $skins_path

ilStyleReplaceResponsiveLogoObjective::$skins_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: