Horde::highlightAccessKey PHP Méthode

highlightAccessKey() public static méthode

Highlights an access key in a label.
public static highlightAccessKey ( string $label, string $accessKey ) : string
$label string The label to highlight the access key in.
$accessKey string The access key to highlight.
Résultat string The HTML version of the label with the access key highlighted.
    public static function highlightAccessKey($label, $accessKey)
    {
        $stripped_label = self::stripAccessKey($label);
        if (empty($accessKey)) {
            return $stripped_label;
        }
        if ($GLOBALS['registry']->nlsconfig->curr_multibyte) {
            /* Prefix parenthesis with the UTF-8 representation of the LRO
             * (Left-to-Right-Override) Unicode codepoint U+202D. */
            return $stripped_label . "‭" . '(<span class="accessKey">' . strtoupper($accessKey) . '</span>' . ')';
        }
        return preg_replace('/_(\\w)/u', '<span class="accessKey">$1</span>', $label);
    }

Usage Example

Exemple #1
0
 /**
  * Renders the tabs.
  *
  * @param string $active_tab  If specified, the name of the active tab. If
  *                            not, the active tab is determined
  *                            automatically.
  * @param string $class       The CSS class of the tabset.
  */
 public function render($active_tab = null, $class = 'tabset')
 {
     $html = "<div class=\"{$class}\"><ul>\n";
     $active = $_SERVER['PHP_SELF'] . $this->_vars->get($this->_name);
     foreach ($this->_tabs as $tab) {
         $link = $this->_addPreserved($tab['link']);
         if (!is_null($this->_name) && !is_null($tab['tabname'])) {
             $link->add($this->_name, $tab['tabname']);
         }
         $classes = array();
         if (isset($tab['class'])) {
             $classes[] = $tab['class'];
         }
         if (!is_null($active_tab) && (string) $active_tab == (string) $tab['tabname'] || $active == $tab['link'] . $tab['tabname']) {
             $classes[] = 'horde-active';
         }
         $class = $classes ? ' class="' . implode(' ', $classes) . '"' : '';
         $id = '';
         if (!empty($tab['id'])) {
             $id = ' id="' . htmlspecialchars($tab['id']) . '"';
         }
         if (!isset($tab['target'])) {
             $tab['target'] = '';
         }
         if (!isset($tab['onclick'])) {
             $tab['onclick'] = '';
         }
         $accesskey = Horde::getAccessKey($tab['title']);
         if (!empty($tab['img'])) {
             $img = Horde_Themes_Image::tag($tab['img']);
         } else {
             $img = '';
         }
         $html .= '<li' . $class . $id . '>' . $link->link(array('target' => $tab['target'], 'onclick' => $tab['onclick'], 'accesskey' => $accesskey)) . $img . Horde::highlightAccessKey(str_replace(' ', '&nbsp;', $tab['title']), $accesskey) . "</a> </li>\n";
     }
     return $html . "</ul></div><br class=\"clear\" />\n";
 }
All Usage Examples Of Horde::highlightAccessKey