PageRenderTime 43ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/baser/plugins/mail/views/helpers/mailform.php

https://github.com/hashing/basercms
PHP | 165 lines | 114 code | 14 blank | 37 comment | 9 complexity | a4f2231a24acfdbd22eb54ecb88a4d7f MD5 | raw file
Possible License(s): MIT
  1. <?php
  2. /* SVN FILE: $Id$ */
  3. /**
  4. * メールフォームヘルパー
  5. *
  6. * PHP versions 5
  7. *
  8. * baserCMS : Based Website Development Project <http://basercms.net>
  9. * Copyright 2008 - 2012, baserCMS Users Community <http://sites.google.com/site/baserusers/>
  10. *
  11. * @copyright Copyright 2008 - 2012, baserCMS Users Community
  12. * @link http://basercms.net baserCMS Project
  13. * @package baser.plugins.mail.views.helpers
  14. * @since baserCMS v 0.1.0
  15. * @version $Revision$
  16. * @modifiedby $LastChangedBy$
  17. * @lastmodified $Date$
  18. * @license http://basercms.net/license/index.html
  19. */
  20. /**
  21. * Include files
  22. */
  23. App::import('Helper', array(BC_HTML_HELPER, BC_FREEZE_HELPER));
  24. /**
  25. * メールフォームヘルパー
  26. *
  27. * @package baser.plugins.mail.views.helpers
  28. *
  29. */
  30. class MailformHelper extends BcFreezeHelper {
  31. /**
  32. * メールフィールドのデータよりコントロールを生成する
  33. *
  34. * @param string $type コントロールタイプ
  35. * @param string $fieldName フィールド文字列
  36. * @param array $options コントロールソース
  37. * @param array $attributes html属性
  38. * @return string htmlタグ
  39. * @access public
  40. */
  41. function control($type,$fieldName,$options, $attributes = array()) {
  42. $attributes['escape'] = false;
  43. switch($type) {
  44. case 'text':
  45. case 'email':
  46. unset($attributes['separator']);
  47. unset($attributes['rows']);
  48. unset($attributes['empty']);
  49. $out = $this->text($fieldName,$attributes);
  50. break;
  51. case 'radio':
  52. unset($attributes['size']);
  53. unset($attributes['rows']);
  54. unset($attributes['maxlength']);
  55. unset($attributes['empty']);
  56. $attributes['legend'] = false;
  57. $attributes['div'] = true;
  58. if(!empty($attributes['separator'])) {
  59. $attributes['separator'] = $attributes['separator'];
  60. }else {
  61. $attributes['separator'] = "&nbsp;&nbsp;";
  62. }
  63. $out = $this->radio($fieldName, $options, $attributes);
  64. break;
  65. case 'select':
  66. unset($attributes['size']);
  67. unset($attributes['rows']);
  68. unset($attributes['maxlength']);
  69. unset($attributes['separator']);
  70. if(isset($attributes['empty'])) {
  71. $showEmpty = $attributes['empty'];
  72. }else {
  73. $showEmpty = true;
  74. }
  75. $out = $this->select($fieldName, $options, null, $attributes, $showEmpty);
  76. break;
  77. case 'pref':
  78. unset($attributes['size']);
  79. unset($attributes['rows']);
  80. unset($attributes['maxlength']);
  81. unset($attributes['separator']);
  82. unset($attributes['empty']);
  83. $out = $this->prefTag($fieldName, null, $attributes);
  84. break;
  85. case 'autozip':
  86. unset($attributes['separator']);
  87. unset($attributes['rows']);
  88. unset($attributes['empty']);
  89. $address1 = $this->__name(array(),$options[1]);
  90. $address2 = $this->__name(array(),$options[2]);
  91. $attributes['onKeyUp'] = "AjaxZip3.zip2addr(this,'','{$address1['name']}','{$address2['name']}')";
  92. $out = $this->Javascript->link('ajaxzip3.js').$this->text($fieldName,$attributes);
  93. break;
  94. case 'check':
  95. unset($attributes['size']);
  96. unset($attributes['rows']);
  97. unset($attributes['maxlength']);
  98. unset($attributes['separator']);
  99. unset($attributes['empty']);
  100. $out = $this->checkbox($fieldName, $attributes);
  101. break;
  102. case 'multi_check':
  103. unset($attributes['size']);
  104. unset($attributes['rows']);
  105. unset($attributes['maxlength']);
  106. unset($attributes['empty']);
  107. if($this->freezed) {
  108. unset($attributes['separator']);
  109. }
  110. $attributes['multiple'] = 'checkbox';
  111. $out = $this->select($fieldName,$options,null,$attributes,false);
  112. break;
  113. case 'date_time_calender':
  114. unset($attributes['size']);
  115. unset($attributes['rows']);
  116. unset($attributes['maxlength']);
  117. unset($attributes['empty']);;
  118. $out = $this->datepicker($fieldName, $attributes);
  119. break;
  120. case 'date_time_wareki':
  121. unset($attributes['size']);
  122. unset($attributes['rows']);
  123. unset($attributes['maxlength']);
  124. unset($attributes['empty']);
  125. $attributes['monthNames'] = false;
  126. $attributes['separator'] = '&nbsp;';
  127. if(isset($attributes['minYear']) && $attributes['minYear'] == 'today') {
  128. $attributes['minYear'] = intval(date('Y'));
  129. }
  130. if(isset($attributes['maxYear']) && $attributes['maxYear'] == 'today') {
  131. $attributes['maxYear'] = intval(date('Y'));
  132. }
  133. $out = $this->dateTime($fieldName,'WMD',null,null,$attributes);
  134. break;
  135. case 'textarea':
  136. $attributes['cols'] = $attributes['size'];
  137. unset($attributes['separator']);
  138. unset($attributes['empty']);
  139. unset($attributes['size']);
  140. $out = $this->textarea($fieldName, $attributes);
  141. break;
  142. case 'hidden':
  143. unset($attributes['separator']);
  144. unset($attributes['rows']);
  145. unset($attributes['empty']);
  146. $out = $this->hidden($fieldName, $attributes);
  147. }
  148. return $out;
  149. }
  150. }
  151. ?>