PageRenderTime 49ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/application/helper/smarty/form/function.textarea.php

http://github.com/integry/livecart
PHP | 65 lines | 40 code | 13 blank | 12 comment | 8 complexity | 1d1c70379f0506ade48d730599cff158 MD5 | raw file
Possible License(s): LGPL-3.0
  1. <?php
  2. /**
  3. * ...
  4. *
  5. * @param array $params
  6. * @param Smarty $smarty
  7. * @return string
  8. *
  9. * @package application.helper.smarty.form
  10. * @author Integry Systems
  11. */
  12. function smarty_function_textarea($params, $smarty)
  13. {
  14. if (empty($params['name']))
  15. {
  16. $params['name'] = $smarty->getTemplateVars('input_name');
  17. }
  18. // @todo: can be removed when all TinyMCE editors are instantiated via Angular
  19. if (empty($params['id']) && empty($params['tinymce']))
  20. {
  21. $params['id'] = uniqid();
  22. }
  23. $formParams = $smarty->_tag_stack[0][1];
  24. $formHandler = $formParams['handle'];
  25. $fieldName = $params['name'];
  26. if (empty($params['ng_model']) && !empty($formParams['model']))
  27. {
  28. $params['ng-model'] = $formParams['model'] . '.' . $params['name'];
  29. unset($params['ng_model']);
  30. }
  31. $params = $smarty->applyFieldValidation($params, $formHandler);
  32. if (!empty($params['tinymce']))
  33. {
  34. if (is_bool($params['tinymce']))
  35. {
  36. $params['tinymce'] = 'getTinyMceOpts()';
  37. }
  38. $params['ui-tinymce'] = $params['tinymce'];
  39. unset($params['tinymce']);
  40. }
  41. // Check permissions
  42. if($formParams['readonly'])
  43. {
  44. $params['readonly'] = 'readonly';
  45. }
  46. $content = '<textarea';
  47. $content = $smarty->appendParams($content, $params);
  48. $content .= '>' . htmlspecialchars($formHandler->get($fieldName), ENT_QUOTES, 'UTF-8') . '</textarea>';
  49. $content = $smarty->formatControl($content, $params);
  50. return $content;
  51. }
  52. ?>