Beispiel #1
0
 /**
  * Returns the language image based on the standard media folder (as configured in the component) or template information
  * The component parameters will be used as folder path within the template or starting with the root directory of your site
  * If the image is found in the current template + folder this reference is returned. Otherwise the reference from
  * JPATH_SITE + folder. The reference is not verified if the image exists!
  *  
  * @param	$language	JFLnaguage language object including the detailed information
  * @return	string		Path to the image found
  */
 public static function getLanguageImageSource($language)
 {
     global $mainframe;
     $params = JComponentHelper::getParams('com_joomfish');
     $media = $params->get('directory_flags', 'components/com_joomfish/images');
     $cur_template = $mainframe->getTemplate();
     $folder = '';
     $file = '';
     if (!empty($language->image)) {
         $file = basename($language->image);
         $folder = dirname($language->image);
     } elseif (!empty($language->shortcode)) {
         $file = $language->shortcode . '.gif';
         $folder = 'flags';
     } else {
         return '';
     }
     if (!self::$imagePath) {
         self::$imagePath = array();
     }
     // check template path first
     $path = $folder != '' ? $folder . '/' . $file : $file;
     if (!isset(self::$imagePath[$path])) {
         jimport('joomla.filesystem.file');
         if (JFile::exists(JPATH_SITE . '/templates/' . $cur_template . '/' . $path)) {
             self::$imagePath[$path] = '/templates/' . $cur_template . '/' . $path;
         } elseif (JFile::exists(JPATH_SITE . DS . $path)) {
             self::$imagePath[$path] = $path;
         } elseif (JFile::exists(JPATH_SITE . DS . $media . DS . $path)) {
             self::$imagePath[$path] = $media . DS . $path;
         } else {
             self::$imagePath[$path] = $path;
         }
     }
     return self::$imagePath[$path];
 }
 /**
  * Returns the language image based on the standard media folder (as configured in the component) or template information
  * The component parameters will be used as folder path within the template or starting with the root directory of your site
  * If the image is found in the current template + folder this reference is returned. Otherwise the reference from
  * JPATH_SITE + folder. The reference is not verified if the image exists!
  *  
  * @param	$language	JFLnaguage language object including the detailed information
  * @return	string		Path to the image found
  */
 public static function getLanguageImageSource($language)
 {
     $params = JComponentHelper::getParams('com_joomfish');
     $media = $params->get('directory_flags', 'media/mod_languages/images');
     $cur_template = JFactory::getApplication()->getTemplate();
     $folder = '';
     $file = '';
     if (!empty($language->image_ext)) {
         $file = basename($language->image_ext);
         $folder = dirname($language->image_ext);
     } elseif (!empty($language->image)) {
         $file = $language->image . '.gif';
         $folder = '';
     } elseif (!empty($language->sef)) {
         $file = $language->sef . '.gif';
         $folder = '';
     } else {
         return '';
     }
     if (!self::$imagePath) {
         self::$imagePath = array();
     }
     // check template path first
     $path = $folder != '' ? $folder . '/' . $file : $file;
     if (!isset(self::$imagePath[$path])) {
         jimport('joomla.filesystem.file');
         if (JFile::exists(JPATH_SITE . '/templates/' . $cur_template . '/' . $path)) {
             self::$imagePath[$path] = '/templates/' . $cur_template . '/' . $path;
         } elseif (JFile::exists(JPATH_SITE . DS . $path)) {
             self::$imagePath[$path] = $path;
         } elseif (JFile::exists(JPATH_SITE . DS . $media . DS . $path)) {
             self::$imagePath[$path] = $media . '/' . $path;
         } else {
             self::$imagePath[$path] = $path;
         }
     }
     return ltrim(self::$imagePath[$path], '/');
 }