Source for file links.php

Documentation is available at links.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Utility class for icons.
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       3.2
  18.  */
  19. abstract class JHtmlLinks
  20. {
  21.     /**
  22.      * Method to generate html code for groups of lists of links
  23.      *
  24.      * @param   array  $groupsOfLinks  Array of links
  25.      *
  26.      * @return  string 
  27.      *
  28.      * @since   3.2
  29.      */
  30.     public static function linksgroups($groupsOfLinks)
  31.     {
  32.         $html array();
  33.  
  34.         if (count($groupsOfLinks0)
  35.         {
  36.             $layout new JLayoutFile('joomla.links.groupsopen');
  37.             $html[$layout->render('');
  38.  
  39.             foreach ($groupsOfLinks as $title => $links)
  40.             {
  41.                 if (isset($links[0]['separategroup']))
  42.                 {
  43.                     $layout new JLayoutFile('joomla.links.groupseparator');
  44.                     $html[$layout->render($title);
  45.                 }
  46.  
  47.                 $layout new JLayoutFile('joomla.links.groupopen');
  48.                 $htmlHeader $layout->render($title);
  49.  
  50.                 $htmlLinks  JHtml::_('links.links'$links);
  51.  
  52.                 if ($htmlLinks != '')
  53.                 {
  54.                     $html[$htmlHeader;
  55.                     $html[$htmlLinks;
  56.  
  57.                     $layout new JLayoutFile('joomla.links.groupclose');
  58.                     $html[$layout->render('');
  59.                 }
  60.             }
  61.  
  62.             $layout new JLayoutFile('joomla.links.groupsclose');
  63.             $html[$layout->render('');
  64.         }
  65.  
  66.         return implode($html);
  67.     }
  68.     /**
  69.      * Method to generate html code for a list of links
  70.      *
  71.      * @param   array  $links  Array of links
  72.      *
  73.      * @return  string 
  74.      *
  75.      * @since   3.2
  76.      */
  77.     public static function links($links)
  78.     {
  79.         $html array();
  80.  
  81.         foreach ($links as $link)
  82.         {
  83.             $html[JHtml::_('links.link'$link);
  84.         }
  85.  
  86.         return implode($html);
  87.     }
  88.  
  89.     /**
  90.      * Method to generate html code for a list of links
  91.      *
  92.      * @param   array  $link  link properties
  93.      *
  94.      * @return  string 
  95.      *
  96.      * @since   3.2
  97.      */
  98.     public static function link($link)
  99.     {
  100.         if (isset($link['access']))
  101.         {
  102.             if (is_bool($link['access']))
  103.             {
  104.                 if ($link['access'== false)
  105.                 {
  106.                     return '';
  107.                 }
  108.             }
  109.             else
  110.             {
  111.                 // Get the user object to verify permissions
  112.                 $user JFactory::getUser();
  113.  
  114.                 // Take each pair of permission, context values.
  115.                 for ($i 0$n count($link['access'])$i $n$i += 2)
  116.                 {
  117.                     if (!$user->authorise($link['access'][$i]$link['access'][$i 1]))
  118.                     {
  119.                         return '';
  120.                     }
  121.                 }
  122.             }
  123.         }
  124.  
  125.         // Instantiate a new JLayoutFile instance and render the layout
  126.         $layout new JLayoutFile('joomla.links.link');
  127.  
  128.         return $layout->render($link);
  129.     }
  130. }

Documentation generated on Tue, 19 Nov 2013 15:07:12 +0100 by phpDocumentor 1.4.3