Lahmizzar Muinela
2013-04-24 4db6bd4ab92cb5ac56d31934119d198608eec93f
install.script.php
@@ -3,7 +3,7 @@
 * @package Projectfork
 * @subpackage Projectfork.Translations.Installer
 *
 * @copyright (C) 2006 - 2013 Projectfork Team. All rights reserved.
 * @copyright (C) 2012 - 2013 Projectfork Translation Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @link http://www.projectfork.net
 **/
@@ -22,6 +22,10 @@
   }
   
   public function preflight($type, $parent) {
      $lang = JFactory::getLanguage();
      $lang->load('pkg_projectfork_languages', dirname(__FILE__) . '/installer', 'en-GB', true);
      $lang->load('pkg_projectfork_languages', dirname(__FILE__) . '/installer', $lang->getTag(), true);
      if (!in_array($type, array('install', 'update'))) return true;
      
      $app = JFactory::getApplication();
@@ -30,17 +34,17 @@
      $table = JTable::getInstance('extension');
      $id = $table->find(array('type'=>'component', 'element'=>'com_projectfork'));
      if(!$id) {
         $app->enqueueMessage(sprintf ( 'Projectfork %s has not been installed, aborting!', '4.x' ), 'notice');
         $app->enqueueMessage(sprintf(JText::_('PKG_PROJECTFORK_LANGUAGES_PFNOTINSTALLED'), '4.x'), 'error');
         return false;
      }
      // TODO: Check installed version of PF4 and translations, give hints and tipps to do everything right!
      
      // Get list of languages to be installed. Only installs languages that are found in your system.
      $source = $parent->getParent()->getPath('source').'/languages';
      $languages = JFactory::getLanguage()->getKnownLanguages();
      
      $files = $parent->manifest->files;
      $installed_langs_html = '<ul>';
      foreach ($languages as $language) {
         $search = JFolder::folders($source, $language['tag']); // no .zip files use "folders" instead
         if (empty($search)) continue;
@@ -49,17 +53,21 @@
         $file = $files->addChild('file', array_pop($search));
         $file->addAttribute('type', 'file');
         $file->addAttribute('id', $this->name . '_' . $language['tag']);
         echo sprintf('<b>Installing detected language:</b> %s - %s ...', $language['tag'], $language['name']);
         $installed_langs_html .= '<li>' . sprintf('<b>%s</b> - %s', $language['tag'], $language['name']);
         if(in_array($language['tag'], $this->uncomplete_lang)) {
            echo ' <span style="color: darkorange;">(This language is not full translated at this moment. Please visit our <a href="https://github.com/projectfork/Translations/wiki" target="_blank">Projectfork Translations - Project Site</a> for more Informations and how to contribute!)';
            $installed_langs_html .= ' ... <span style="color: darkorange;">(' . sprintf(JText::_('PKG_PROJECTFORK_LANGUAGES_NOTFULL_TRANSLATED'), '<a href="https://github.com/projectfork/Translations/wiki" target="_blank">Projectfork Translations Team</a>') . ')';
         }
         echo '<br />';
         $installed_langs_html .= '</li>';
      }
      $installed_langs_html .= '</ul>';
      
      if (empty($files)) {
         // No packages to install: replace failure message with something that's more descriptive.
         $app->enqueueMessage(sprintf ( 'Your site is English only. There\'s no need to install an other Projectfork Language! If you want to install a different language, you have to install a different core language first!' ), 'notice');
         // No packages to install
         $app->enqueueMessage(sprintf(JText::_('PKG_PROJECTFORK_LANGUAGES_ENGLISH_ONLY')), 'notice');
         return false;
      } else {
         // Package was installation successfull with detected languages
         echo JText::_('PKG_PROJECTFORK_LANGUAGES_INSTALLED_DETECTED_SUCCESS') . $installed_langs_html;
      }
      
      return true;