PageRenderTime 123ms CodeModel.GetById 60ms app.highlight 9ms RepoModel.GetById 52ms 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
  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 */
 23App::import('Helper', array(BC_HTML_HELPER, BC_FREEZE_HELPER));
 24/**
 25 * メールフォームヘルパー
 26 *
 27 * @package baser.plugins.mail.views.helpers
 28 *
 29 */
 30class 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
 43		$attributes['escape'] = false;
 44
 45		switch($type) {
 46
 47			case 'text':
 48			case 'email':
 49				unset($attributes['separator']);
 50				unset($attributes['rows']);
 51				unset($attributes['empty']);
 52				$out = $this->text($fieldName,$attributes);
 53				break;
 54
 55			case 'radio':
 56				unset($attributes['size']);
 57				unset($attributes['rows']);
 58				unset($attributes['maxlength']);
 59				unset($attributes['empty']);
 60				$attributes['legend'] = false;
 61				$attributes['div'] = true;
 62				if(!empty($attributes['separator'])) {
 63					$attributes['separator'] = $attributes['separator'];
 64				}else {
 65					$attributes['separator'] = "&nbsp;&nbsp;";
 66				}
 67				$out = $this->radio($fieldName, $options, $attributes);
 68				break;
 69
 70			case 'select':
 71				unset($attributes['size']);
 72				unset($attributes['rows']);
 73				unset($attributes['maxlength']);
 74				unset($attributes['separator']);
 75				if(isset($attributes['empty'])) {
 76					$showEmpty = $attributes['empty'];
 77				}else {
 78					$showEmpty = true;
 79				}
 80				$out = $this->select($fieldName, $options, null, $attributes, $showEmpty);
 81				break;
 82
 83			case 'pref':
 84				unset($attributes['size']);
 85				unset($attributes['rows']);
 86				unset($attributes['maxlength']);
 87				unset($attributes['separator']);
 88				unset($attributes['empty']);
 89				$out = $this->prefTag($fieldName, null, $attributes);
 90				break;
 91
 92			case 'autozip':
 93				unset($attributes['separator']);
 94				unset($attributes['rows']);
 95				unset($attributes['empty']);
 96				$address1 = $this->__name(array(),$options[1]);
 97				$address2 = $this->__name(array(),$options[2]);
 98				$attributes['onKeyUp'] = "AjaxZip3.zip2addr(this,'','{$address1['name']}','{$address2['name']}')";
 99				$out = $this->Javascript->link('ajaxzip3.js').$this->text($fieldName,$attributes);
100				break;
101
102			case 'check':
103				unset($attributes['size']);
104				unset($attributes['rows']);
105				unset($attributes['maxlength']);
106				unset($attributes['separator']);
107				unset($attributes['empty']);
108				$out = $this->checkbox($fieldName, $attributes);
109				break;
110
111			case 'multi_check':
112				unset($attributes['size']);
113				unset($attributes['rows']);
114				unset($attributes['maxlength']);
115				unset($attributes['empty']);
116				if($this->freezed) {
117					unset($attributes['separator']);
118				}
119				$attributes['multiple'] = 'checkbox';
120				$out = $this->select($fieldName,$options,null,$attributes,false);
121				break;
122
123			case 'date_time_calender':
124				unset($attributes['size']);
125				unset($attributes['rows']);
126				unset($attributes['maxlength']);
127				unset($attributes['empty']);;
128				$out = $this->datepicker($fieldName, $attributes);
129				break;
130
131			case 'date_time_wareki':
132				unset($attributes['size']);
133				unset($attributes['rows']);
134				unset($attributes['maxlength']);
135				unset($attributes['empty']);
136				$attributes['monthNames'] = false;
137				$attributes['separator'] = '&nbsp;';
138				if(isset($attributes['minYear']) && $attributes['minYear'] == 'today') {
139					$attributes['minYear'] = intval(date('Y'));
140				}
141				if(isset($attributes['maxYear']) && $attributes['maxYear'] == 'today') {
142					$attributes['maxYear'] = intval(date('Y'));
143				}
144				$out = $this->dateTime($fieldName,'WMD',null,null,$attributes);
145				break;
146
147			case 'textarea':
148				$attributes['cols'] = $attributes['size'];
149				unset($attributes['separator']);
150				unset($attributes['empty']);
151				unset($attributes['size']);
152				$out = $this->textarea($fieldName, $attributes);
153				break;
154			case 'hidden':
155				unset($attributes['separator']);
156				unset($attributes['rows']);
157				unset($attributes['empty']);
158				$out = $this->hidden($fieldName, $attributes);
159		}
160		return $out;
161
162	}
163	
164}
165?>