PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/application/helper/smarty/block.language.php

http://github.com/integry/livecart
PHP | 72 lines | 51 code | 11 blank | 10 comment | 7 complexity | 51abf582a595e754702a309baaf04a8b MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * Language forms
  4. *
  5. * @package application.helper.smarty
  6. * @author Integry Systems
  7. *
  8. * @package application.helper.smarty
  9. */
  10. function smarty_block_language($params, $content, Smarty_Internal_Template $smarty, &$repeat)
  11. {
  12. //$smarty = $smarty->smarty;
  13. $app = $smarty->smarty->getApplication();
  14. if (!$app->getLanguageSetArray())
  15. {
  16. return false;
  17. }
  18. if ($repeat)
  19. {
  20. $app->languageBlock = $app->getLanguageSetArray();
  21. $smarty->assign('languageBlock', $app->languageBlock);
  22. $smarty->assign('lang', array_shift($app->languageBlock));
  23. $app->langHeadDisplayed = false;
  24. $user = SessionUser::getUser();
  25. foreach ($app->getLanguageSetArray() as $lang)
  26. {
  27. $userPref = $user->getPreference('tab_lang_' . $lang['ID']);
  28. $isHidden = is_null($userPref) ? !empty($params['hidden']) : $userPref == 'false';
  29. $classNames[$lang['ID']] = $isHidden ? 'hidden' : '';
  30. }
  31. $app->langClassNames = $classNames;
  32. }
  33. else
  34. {
  35. if (!trim($content))
  36. {
  37. $repeat = false;
  38. return false;
  39. }
  40. if ($app->languageBlock)
  41. {
  42. $repeat = true;
  43. }
  44. $contentLang = $smarty->getTemplateVars('lang');
  45. $content = '<tab class="lang_' . $contentLang['ID'] . '" heading="' . $contentLang['originalName'] . '">' . $content . '</tab>';
  46. if (!$app->langHeadDisplayed)
  47. {
  48. $smarty->assign('classNames', $app->langClassNames);
  49. $content = $smarty->fetch('block/backend/langFormHead.tpl') . $content;
  50. $app->langHeadDisplayed = true;
  51. }
  52. $smarty->assign('lang', array_shift($app->languageBlock));
  53. // form footer
  54. if (!$repeat)
  55. {
  56. $content .= $smarty->fetch('block/backend/langFormFoot.tpl');
  57. }
  58. return $content;
  59. }
  60. }
  61. ?>