]> _ Git - cubeextranet.git/commitdiff
wip #3756
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Jul 2020 18:32:01 +0000 (18:32 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Fri, 3 Jul 2020 18:32:01 +0000 (18:32 +0000)
inc/ws/Util/html5/master/class.ws.html5.links.php

index 6eb0c7bce32c11b6ed2709ba1121cf0396995ac3..e342d81695cb322b6415eabd10ade0e17630463d 100644 (file)
@@ -41,6 +41,7 @@ class wsHTML5Link
     public $border = 0;
     public $borderColor = '#ffffff';
     public $maxWidth = 0;
+    protected $role = 'button';
 
     protected $_init;
 
@@ -319,6 +320,21 @@ class wsHTML5Link
         $this->init();
     }
 
+    public function getTooltipAttribute($t = null)
+    {
+        if (null === $t) {
+            $t = $this->getTooltip();
+        }
+        if ($t !== false) {
+            $escaped = htmlspecialchars($t, ENT_QUOTES);
+            $tooltip = ' data-tooltip="' . $escaped . '"';
+            $tooltip .= ' aria-label="' . $escaped . '"';
+            return $tooltip;
+        } else {
+            return '';
+        }
+    }
+
     public function overlapDoublePage()
     {
         return ($this->page % 2 == 0 && $this->left + $this->width > $this->compiler->width);
@@ -381,7 +397,7 @@ class wsHTML5Link
 
     public function getAdditionnalContent()
     {
-        $res = '';
+        $res = ' role="' . $this->role . '"';
         if ($this->maxWidth > 0) {
             $res .= ' data-max-width="' . $this->maxWidth . '"';
         }
@@ -529,6 +545,7 @@ class wsHTML5Link
 
 class normalLink extends wsHTML5Link
 {
+    protected $role = 'link';
 
     public function getHTMLContent()
     {
@@ -540,16 +557,14 @@ class normalLink extends wsHTML5Link
         if (count($class)) {
             $attrs .= ' class="' . implode(' ', $class) . '"';
         }
-        $t = $this->getTooltip();
-        if ($t !== false) {
-            $attrs .= ' data-tooltip="' . htmlentities($t, ENT_QUOTES) . '"';
-        }
+        $attrs .= $this->getTooltipAttribute();
         if (isset($this->extra->blinkdelay)) {
             $attrs .= ' data-blinkdelay="' . intval($this->extra->blinkdelay) . '"';
         }
         return '<a href="' . $this->getURL() . '" data-type="' . $this->type . '" target="' . $this->getTarget() . '"' . $attrs . $this->getAdditionnalContent() . $this->getTrack() . '></a>';
     }
 
+
     public function getTrack()
     {
         return '';
@@ -656,6 +671,11 @@ class htmlMultimediaImage extends wsHTML5Link
         return $alt;
     }
 
+    public function getAdditionnalContent()
+    {
+        return parent::getAdditionnalContent() . ' aria-hidden="true"';
+    }
+
 }
 
 class htmlMultimediaPopupLink extends htmlMultimediaPopupImage
@@ -784,6 +804,8 @@ class eventOverlayLink extends wsHTML5Link
 
 class webLink extends normalLink
 {
+    protected $role = 'link';
+
     public function getURL()
     {
         $res = str_replace('"', '\'', wsHTML5Link::getUniversalLocation($this->to));
@@ -817,6 +839,7 @@ class webLink extends normalLink
 
 class mailLink extends normalLink
 {
+    protected $role = 'link';
 
     public function getURL()
     {
@@ -842,6 +865,7 @@ class mailLink extends normalLink
 
 class phoneLink extends mailLink
 {
+    protected $role = 'link';
 
     public function getURL()
     {
@@ -877,6 +901,11 @@ class internalLink extends normalLink
         }
     }
 
+    public function getAdditionnalContent()
+    {
+        return parent::getAdditionnalContent() . ' role="button"';
+    }
+
     public function getDefaultTooltip()
     {
         return 'go to page';
@@ -900,8 +929,6 @@ class videoLink extends wsHTML5Link
 
     public function getHTMLContent()
     {
-
-
         $this->copyExternalFile($this->to, true);
 
         $w = round($this->width * $this->getCssScale());
@@ -1298,6 +1325,7 @@ class inlineSlideshowLink extends contentLink
 
 class fileLink extends normalLink
 {
+    protected $role = 'link';
 
     public function getURL()
     {
@@ -1640,6 +1668,7 @@ class audioLink extends wsHTML5Link
 
 class wescoLink extends normalLink
 {
+    protected $role='link';
     public static function _getURL($to)
     {
         return self::_getURLOfType('wesco', $to);
@@ -1675,6 +1704,7 @@ class wescoLink extends normalLink
 
 class pierronLink extends normalLink
 {
+    protected $role = 'link';
 
     public function getURL()
     {
@@ -1753,11 +1783,8 @@ class inpesPopinLink extends htmlMultimediaLink
         if (count($class)) {
             $c = ' class="' . implode(' ', $class) . '"';
         }
-        $tooltip = '';
-        $t = $this->getTooltip();
-        if ($t !== false) {
-            $tooltip = ' data-tooltip="' . htmlspecialchars($t, ENT_QUOTES) . '"';
-        }
+        $tooltip = $this->getTooltipAttribute();
+
         return '<a href="#" ' . $tooltip . $c . $this->getAdditionnalContent() . '></a>';
     }
 
@@ -1819,6 +1846,7 @@ class statsTagLink extends wsHTML5Link
 
 class flfLink extends wescoLink
 {
+    protected $role = 'link';
 
     public function getURL()
     {
@@ -1854,6 +1882,8 @@ class haguenauManifLink extends internalLink
 
 class customLink extends wescoLink
 {
+    protected $role = 'link';
+
     public static function getCustomInstance($id, $init, &$compiler)
     {
         $e = explode(':', $init['to']);