v1.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace zin;
  3. class password extends wg
  4. {
  5. /**
  6. * @var mixed[]
  7. */
  8. protected static $defineProps = array(
  9. 'id?: string="password1"',
  10. 'name?: string="password1"',
  11. 'checkStrength?: bool=false',
  12. 'strengthID?: string="passwordStrength"',
  13. 'strengthClass?: string="passwordStrength"'
  14. );
  15. public static function getPageJS()
  16. {
  17. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  18. }
  19. /**
  20. * @return mixed[]|\zin\node
  21. */
  22. protected function build()
  23. {
  24. global $app, $config, $lang;
  25. $app->loadLang('user');
  26. $jsRoot = $app->getWebRoot() . 'js/';
  27. list($id, $name, $checkStrength, $strengthID, $strengthClass) = $this->prop(array('id', 'name', 'checkStrength', 'strengthID', 'strengthClass'));
  28. return $checkStrength ? array
  29. (
  30. h::jsCall('$.getLib', 'md5.js', array('root' => $jsRoot)),
  31. jsVar('window.strengthClass', $strengthClass),
  32. jsVar('window.passwordStrengthList', $lang->user->passwordStrengthList),
  33. inputGroup
  34. (
  35. input
  36. (
  37. setID($id),
  38. on::keyup('checkPassword'),
  39. set::type('password'),
  40. set::name($name),
  41. set::placeholder(zget($lang->user->placeholder->passwordStrength, isset($config->safe->mode) ? $config->safe->mode : '1', ''))
  42. ),
  43. span
  44. (
  45. setID($strengthID),
  46. setClass("input-group-addon {$strengthClass} hidden")
  47. )
  48. )
  49. ) : input
  50. (
  51. set::type('password'),
  52. set::name($name),
  53. set($this->getRestProps())
  54. );
  55. }
  56. }