Beispiel #1
0
 public static function header($form = array())
 {
     if (isset($form['template'])) {
         form::$template = arr::take('template', $form);
     }
     $attrs['class'] = isset($form['class']) ? $form['class'] : 'form';
     $attrs['method'] = isset($form['method']) ? $form['method'] : 'post';
     $attrs['action'] = isset($form['action']) ? $form['action'] : url::current();
     //加载表头
     $html[] = '';
     $html[] = '<form' . html::attributes($attrs) . '>';
     $html[] = field::hidden(array('name' => '_REFERER', 'value' => request::referer()));
     $html[] = field::hidden(array('name' => '_FORMHASH', 'value' => form::hash()));
     //加载常用js
     $html[] = html::script(url::common() . '/js/jquery.validate.js');
     $html[] = html::script(url::common() . '/js/jquery.validate.additional.js');
     $html[] = html::script(url::common() . '/js/jquery.form.js');
     //表单头部
     if (isset($form['title']) || isset($form['description'])) {
         $html[] = '<div class="form-header clearfix">';
         $html[] = isset($form['icon']) ? '		<div class="form-icon"></div>' : '';
         $html[] = isset($form['title']) ? '		<div class="form-title">' . $form['title'] . '</div>' : '';
         $html[] = isset($form['description']) ? '		<div class="form-description">' . $form['description'] . '</div>' : '';
         $html[] = '</div>';
     }
     //表单body部分开始
     $html[] = '<div class="form-body">';
     echo implode("\n", $html);
 }
Beispiel #2
0
 /**
  * 自定义一个图片控件,该控件只对当前控制器页面有效
  *  
  * @param array 控件参数
  */
 public function image($attrs)
 {
     $html = array();
     $html[] = field::hidden($attrs);
     $html[] = '<div class="textarea" style="margin-top:-1px;height:100px;">';
     $html[] = '	<ul class="zotop-image-list" id="' . $attrs['name'] . '-images">';
     for ($i = 0; $i < 10; $i++) {
         $image = url::theme() . '/image/userface/' . $i . '.gif';
         $class = $attrs['value'] == $image ? 'selected' : 'normal';
         $html[] = '		<li class="' . $class . '"><a href="javascript:void(0);" onfocus="blur()"><img src="' . $image . '" style="width:64px;height:64px;"></a></li>';
     }
     $html[] = '	</ul>';
     $html[] = '</div>';
     $html[] = '
     <script>
     	$(function(){
 			var name = "' . $attrs['name'] . '";
     		var id = "#' . $attrs['name'] . '-images";
     		$(id).find("li").click(function(){
 				var image = $(this).find("img").attr("src");
 				$(this).parents("ul").find("li").removeClass("selected");
 				$(this).addClass("selected");
 				$("#"+name).val(image);
 			})
 		});        
     </script>
     ';
     return implode("\n", $html);
 }
Beispiel #3
0
 public static function header($form = array())
 {
     if (is_string($form) || is_numeric($form)) {
         $form = array('globalid' => $form);
     }
     if (is_array($form)) {
         $form += array('class' => 'form', 'method' => 'post', 'action' => url::location(), 'globalid' => 0);
     }
     $html[] = '';
     if (arr::take('valid', $form) !== false) {
         $html[] = html::script('$common/js/jquery.validate.js');
     }
     if (arr::take('ajax', $form) !== false) {
         $html[] = html::script('$common/js/jquery.form.js');
     }
     $icon = arr::take('icon', $form);
     $title = arr::take('title', $form);
     $description = arr::take('description', $form);
     $globalid = arr::take('globalid', $form);
     $template = arr::take('template', $form);
     if (!empty($template)) {
         form::$template = $template;
     }
     //加载表头
     $html[] = '<form' . html::attributes($form) . '>';
     $html[] = field::hidden(array('name' => '_REFERER', 'value' => url::referer()));
     $html[] = field::hidden(array('name' => '_FORMHASH', 'value' => form::hash()));
     $html[] = field::hidden(array('name' => '_GLOBALID', 'value' => empty($globalid) ? form::globalid() : $globalid));
     //表单头部
     if (isset($title) || isset($description)) {
         $html[] = '<div class="form-header clearfix">';
         if (isset($icon)) {
             $html[] = '<div class="form-icon"><div class="zotop-icon zotop-icon-' . $icon . '"></div></div>';
         }
         if (isset($title)) {
             $html[] = '	<div class="form-title">' . $title . '</div>';
         }
         if (isset($description)) {
             $html[] = '	<div class="form-description">' . $description . '</div>';
         }
         $html[] = '</div>';
     }
     $html[] = '<div class="form-body clearfix">';
     $html[] = '';
     echo implode("\n", $html);
 }
Beispiel #4
0
 public static function header($header = array())
 {
     if (isset($header['template'])) {
         form::$template = arr::take('template', $header);
     }
     $attrs['class'] = isset($header['class']) ? $header['class'] : 'form';
     $attrs['method'] = isset($header['method']) ? $header['method'] : 'post';
     $attrs['action'] = isset($header['action']) ? $header['action'] : url::current();
     $html[] = '';
     $html[] = '<form' . html::attributes($attrs) . '>';
     $html[] = isset($header['title']) ? '<div class="form-title">' . $header['title'] . '</div>' : '';
     $html[] = isset($header['description']) ? '<div class="form-description">' . $header['description'] . '</div>' : '';
     $html[] = field::hidden(array('name' => '_REFERER', 'value' => request::referer()));
     $html[] = html::script(url::common() . '/js/jquery.validate.js');
     $html[] = html::script(url::common() . '/js/jquery.validate.additional.js');
     $html[] = html::script(url::common() . '/js/jquery.form.js');
     $html[] = html::script(url::common() . '/js/zotop.form.js');
     echo implode("\n", $html);
 }
Beispiel #5
0
 public static function header($form = array())
 {
     if (is_string($form)) {
         $form['description'] = $form;
     }
     form::$template = isset($form['template']) ? $form['template'] : form::$template;
     form::$globalid = isset($form['globalid']) ? $form['globalid'] : form::$globalid;
     //form 标签
     $attrs['class'] = isset($form['class']) ? $form['class'] : 'form';
     $attrs['method'] = isset($form['method']) ? $form['method'] : 'post';
     $attrs['target'] = isset($form['target']) ? $form['target'] : '';
     $attrs['action'] = isset($form['action']) ? $form['action'] : url::location();
     if (isset($form['enctype']) || isset($form['upload'])) {
         $attrs['enctype'] = 'multipart/form-data';
     }
     //加载表头
     $html[] = '';
     $html[] = '<form' . html::attributes($attrs) . '>';
     $html[] = field::hidden(array('name' => '_REFERER', 'value' => request::referer()));
     $html[] = field::hidden(array('name' => '_FORMHASH', 'value' => form::hash()));
     $html[] = field::hidden(array('name' => '_GLOBALID', 'value' => form::globalid()));
     //加载常用js
     if ($form['valid'] !== false) {
         $html[] = html::script(ZOTOP_APP_URL_JS . '/jquery.validate.js');
     }
     if ($form['ajax'] !== false) {
         $html[] = html::script(ZOTOP_APP_URL_JS . '/jquery.form.js');
     }
     //表单头部
     if (isset($form['title']) || isset($form['description'])) {
         $html[] = '<div class="form-header clearfix">';
         $html[] = isset($form['title']) ? '		<div class="form-title">' . $form['title'] . '</div>' : '';
         $html[] = isset($form['description']) ? '		<div class="form-description">' . $form['description'] . '</div>' : '';
         $html[] = '</div>';
     }
     //表单body部分开始
     $html[] = '<div class="form-body">';
     echo implode("\n", $html);
 }
Beispiel #6
0
 /**
  * 标题输入框,含有标题样式
  *
  * @param $attrs array 控件参数
  * @return string 控件代码
  */
 public static function title($attrs)
 {
     $style = arr::decode($attrs['style'], ';', ':');
     $html[] = html::script('$common/js/jquery.colorpicker.js');
     $html[] = html::script('$common/js/zotop.title.js');
     $html[] = '<div class="field-wrapper clearfix">';
     $html[] = '	' . field::text($attrs);
     $html[] = '	' . field::hidden(array('name' => $attrs['name'] . '_color', 'id' => $attrs['name'] . '_style', 'class' => 'short', 'value' => $style['color']));
     $html[] = '	' . field::hidden(array('name' => $attrs['name'] . '_weight', 'id' => $attrs['name'] . '_weight', 'class' => 'short', 'value' => $style['font-weight']));
     $html[] = '	<span class="field-handle">';
     $html[] = '		<a class="setweight" style="display:inline-block;" valueto="' . $attrs['name'] . '_weight" weightto="' . $attrs['name'] . '" title="' . zotop::t('加粗') . '"><span class="zotop-icon zotop-icon-b"></span></a>';
     $html[] = '		<a class="setcolor" style="display:inline-block;" valueto="' . $attrs['name'] . '_color" colorto="' . $attrs['name'] . '" title="' . zotop::t('色彩') . '"><span class="zotop-icon zotop-icon-setcolor ' . $style['font-weight'] . '"></span></a>';
     $html[] = '	</span>';
     $html[] = '</div>';
     return implode("\n", $html);
 }