From 4192be6a6d91ce47ba47a05171497ae54d9e04e9 Mon Sep 17 00:00:00 2001 From: Lahmizzar Muinela <lahmizzar@devxive.com> Date: Wed, 24 Apr 2013 16:01:50 -0400 Subject: [PATCH] adding minimum_perc for pulling translations --- install.script.php | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 45 insertions(+), 9 deletions(-) diff --git a/install.script.php b/install.script.php index 5e40173..dff2045 100644 --- a/install.script.php +++ b/install.script.php @@ -3,7 +3,7 @@ * @package Projectfork * @subpackage Projectfork.Translations.Installer * - * @copyright (C) 2006 - 2013 Projectfork Team. All rights reserved. + * @copyright (C) 2006 - 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(); @@ -29,18 +33,41 @@ // Do not install if Projectfork 4 doesn't exist. $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'); + if($id) { + $app->enqueueMessage(sprintf(JText::_('PKG_PROJECTFORK_LANGUAGES_PFNOTINSTALLED'), '4.x'), 'error'); + + $nopf_installed = ' + <div style="display: inline-block;"> + <div style="background: url(https://projectfork.net/templates/hydra/img/logo.png) no-repeat 50% 50% #698C00; height: 63px; width: 205px; border: 6px solid #567300; padding: 10px; border-top-left-radius: 5px; border-bottom-left-radius: 5px; float: left;"></div> + <div onclick="PFInstaller()" style="background-color: #698C00; cursor: pointer; height: 63px; border-width: 6px; border-style: solid; border-color: #567300; border-left: 0px; padding: 10px; color: white; font-size: 25px; line-height: 60px; float: left; text-indent: 0; text-align: center;">' . JText::_('PKG_PROJECTFORK_LANGUAGES_INSTALLNOW') . '</div> + <div onclick="PFDownload()" style="background-color: #42A9CA; cursor: pointer; height: 63px; border: 6px solid #2E88A5; padding: 10px; color: white; font-size: 25px; line-height: 60px; float: left; text-indent: 0; text-align: center;">' . JText::_('PKG_PROJECTFORK_LANGUAGES_DOWNLOAD_COMMUNITY') . '</div> + <div onclick="PFOrderPro()" style="background-color: #F7A700; cursor: pointer; height: 63px; border: 6px solid #BE8100; padding: 10px; color: white; font-size: 25px; line-height: 60px; float: left; text-indent: 0; text-align: center; border-top-right-radius: 5px; border-bottom-right-radius: 5px;">' . JText::_('PKG_PROJECTFORK_LANGUAGES_ORDER_PRO') . '</div> + </div> + <script type="text/javascript"> + PFInstaller = function(pressbutton) { + var form = document.getElementById("adminForm"); + form.install_url.value = "https://projectfork.net/downloads/projectfork-4/projectfork-4-4-0-0/pkgprojectfork4-0-0-zip?format=raw"; + Joomla.submitbutton4(); + } + PFDownload = function(pressbutton) { + window.open("https://projectfork.net","_blank"); + } + PFOrderPro = function(pressbutton) { + window.open("https://projectfork.net/pro","_blank"); + } + </script> + '; + $app->enqueueMessage($nopf_installed, 'notice'); 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 = '<div style="inline-block;"><ul>'; + foreach ($languages as $language) { $search = JFolder::folders($source, $language['tag']); // no .zip files use "folders" instead if (empty($search)) continue; @@ -49,17 +76,26 @@ $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 - %s</b>', $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></div>'; 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'); + $app->enqueueMessage(sprintf(JText::_('PKG_PROJECTFORK_LANGUAGES_ENGLISH_ONLY')), 'notice'); return false; + } else { + // Override XML-DIV-NOPF-Installer-Placeholder if PF is installed + $success_html_output = '<div style="display: inline-block; margin-bottom: 25px;">'; + $success_html_output .= '<div style="background: url(https://projectfork.net/templates/hydra/img/logo.png) no-repeat 50% 50% #698C00; height: 63px; width: 205px; border: 6px solid #567300; padding: 10px; border-top-left-radius: 5px; border-bottom-left-radius: 5px; float: left;"></div>'; + $success_html_output .= '<div style="background-color: #698C00; height: 63px; border-width: 6px; border-style: solid; border-color: #567300; border-left: 0px; padding: 10px; color: white; font-size: 25px; line-height: 60px; float: left; text-indent: 0; text-align: center; border-top-right-radius: 5px; border-bottom-right-radius: 5px;">' . JText::_('PKG_PROJECTFORK_LANGUAGES_INSTALLED_DETECTED') . '</div>'; + $success_html_output .= '</div>'; + echo $success_html_output; + echo $installed_langs_html; } return true; -- Gitblit v1.9.1