J4.x

Gestion améliorée des substitutions

From Joomla! Documentation

Revision as of 13:01, 4 August 2018 by Opware2000 (talk | contribs) (Created page with "Affichage des différences")
GSoC 2018
Documentation
sur la gestion améliorée des substitutions
Joomla! 
4.x

Introduction

Ce projet ajoute une fonction de vérification de mise à jour à Joomla de sorte que si un template est modifié ou mis à jour, il informe l'utilisateur que l'un des fichiers de base de leur template est modifié avec la mise à jour, pour éviter les problèmes de sécurité ou de fonctionnalité et ils peuvent ajuster leur modifications avant que quelqu'un puisse s'en rendre compte.

Lien du dépôt du projet : https://github.com/joomla-projects/gsoc18_override_management

Obtenir une longueur d'avance grâce à une gestion améliorée de l'override

Notes

Si vous êtes nouveau dans le développement Joomla, et ne savent pas grand-chose sur le gestionnaire de modèles et les Overrides, veuillez lire :

  1. Comment utiliser le Gestionnaire de templates
  2. Les substitutions de mise en page dans Joomla

Maintenant, si vous vous êtes familiarisé avec la façon d'utiliser le gestionnaire de modèles et les types d'Overrides dans Joomla, alors, passons en revue les fonctionnalités de ce projet.

  • Substitutions supportées
  • Affichage des différences
  • Override - Quick Icon Notification Plugin
  • Installer - Override Plugin
  • Updated - Override History

Types de substitutions supportées par cette fonctionnalité

It does not support Alternative Layout in which filename get renamed to something else and js, css overrides. This feature supports these override files listed in Create Override tab. Example:

Diff view between core and override files

This feature shows the difference between the core file and the override file. When you open any override file to edit you can see two buttons or switchers in the top right corner of the page if core file of that file is exited.

Des boutons comme ceux-ci :

Buttons
Buttons

Here, you can control the hide and show view of diff view and core file view. In the next image, you will see the location of the core file and diff view in the template manager.

Vous ne pouvez pas modifier le fichier natif.

How diff view is working

When you click on any override file to edit it, it calls a function method getCoreFile which receives the two parameters path of the override file in the template. Example : /html/layouts/joomla/form/field/user.php and the client path of the file whether it belongs to Site or Administrator. Then, based on these information it returns the path of the core file if it exists. For showing the diff between the core and override files we used jsdiff library.

Override - Quick Icon Notification Plugin

A quick icon notification plugin which shows the notification in cpanel and it shows the total updated overrides from all templates. When overrides are updated then the quick icon shows something like in the example below:

Quick Icon
Quick Icon

When you click on it, it will redirect you to Templates which contain the list of your templates with their description. You'll see a new column header Overrides showing the number of override updated which belongs to the template. If nothing has been updated in the template override it will show a Up to date badge.

Templates
Templates

How quick icon is working

It makes an AJAX call to the TemplateController.php which returns the information and displays a notification when such overrides are updated.

Attention

Quick icon notification plugin only works or able to fetch data if installer/override plugin is enabled. If installer/override is disabled then you will see this error message in quick icon.

Enable
Enable

If you click on the quick icon you will be redirected to the installer/override plugin settings where you can edit the settings of the plugin.

Installer - Override Plugin

This plugin is the main part of this feature. It allows to find the correct updated overrides during the extension install or update and Joomla update.

Installer Override
Installer Override

How installer override plugin is working

This plugin works on 6 events:

  • onExtensionBeforeUpdate
  • onExtensionAfterUpdate
  • onInstallerBeforeInstaller
  • onInstallerAfterInstaller
  • onJoomlaBeforeUpdate
  • onJoomlaAfterUpdate

Which collect all overrides core file md5_file() hash before update and after update then compairs both values. Then, find the correct changed or updated file. And, store information in #__templates_overrides table.

Updated - Override History

You can access this from the Updated Files tab in a template. This is a list view that shows the list of updated overrides which do belongs to that template.

There are many options available to manage list. Where you can check the status of override file history whether is checked or not, created date, date of change and update action like: whether it belongs to (Joomla Update, Extension Update or Extension Install).

Note

These information are only history so if you checked the updated override changes then, you can delete the history, as not needed anymore.