function print_date_element($label, $params, $required = false, $info_text = null)
{
    if (empty($params['class'])) {
        $params['class'] = 'date_input';
    } else {
        $params['class'] .= ' date_input';
    }
    $element = new form_element_input($label, $params, $required, $info_text);
    echo $element->get_html();
}
Пример #2
0
 public function __construct($name, $param = array())
 {
     parent::__construct($name, $param);
     $this->type = 'button';
     if (isset($param['onclick'])) {
         $this->onclick = $param['onclick'];
     }
 }
Пример #3
0
 public function render()
 {
     if ($this->uniform) {
         $opt = array();
         $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/uniform/jquery.uniform.js')->append_inline('js', '$("input[type=radio][name=\'' . $this->name . '\']").uniform(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');');
         if ($this->uniform->css) {
             $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/uniform/themes/default/css/uniform.default.css');
         }
     }
     return parent::render();
 }
Пример #4
0
 public function __construct($name, $param = array())
 {
     parent::__construct($name, $param);
     $this->controller = isset($param['controller']) ? $param['controller'] : 'cindex';
     $this->action = isset($param['action']) ? $param['action'] : 'index';
     $this->cid = isset($param['cid']) ? $param['cid'] : $this->view->control()->config->param->id;
     if (!$this->cid) {
         $s = (int) session::get($this->controller . '_clink');
         if ($s) {
             $this->cid = $s;
         } else {
             $this->cid = time();
             session::set($this->controller . '_clink', $this->cid);
         }
     }
 }
Пример #5
0
 public function render()
 {
     if ($this->ui) {
         $opt = array();
         if ($this->ui->opt) {
             $opt = array_merge($opt, $this->ui->opt->to_array());
         }
         $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.datepicker.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/i18n/jquery.ui.datepicker-' . $this->ui->lang . '.js')->append_inline('js', '$("input[name=\'' . $this->name . '\']").' . ($this->time ? 'datetimepicker' : 'datepicker') . '(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');');
         if ($this->time) {
             $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/timepicker/jquery-ui-timepicker-addon.js');
         }
         $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.datepicker.css');
         if ($this->time) {
             $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/timepicker/jquery-ui-timepicker-addon.css');
         }
     }
     return parent::render();
 }
Пример #6
0
 public function render()
 {
     $opt = array();
     if ($this->map_type) {
         $opt['map_type'] = $this->map_type;
     }
     if ($this->center) {
         $opt['center'] = $this->center->to_array();
     }
     if ($this->zoom) {
         $opt['zoom'] = $this->zoom;
     }
     $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/coord/coord.js');
     if ($this->map_type == 'yandex') {
         $this->view->messify->append('js', 'http://api-maps.yandex.ru/2.1/?load=package.standard&lang=ru', array('remote' => true));
     } else {
         if ($this->map_type == 'google') {
             $this->view->messify->append('js', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&language=ru', array('remote' => true));
         }
     }
     $this->view->messify->append_inline('js', '$("input[name=\'' . $this->name . '\']").coord(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');');
     return parent::render();
 }
Пример #7
0
 public function __construct($name, $param = array())
 {
     parent::__construct($name, $param);
     $this->type = 'hidden';
 }
Пример #8
0
    public function render()
    {
        if ($this->uploadifive) {
            session::set('uploadifive_' . $this->name, array('path' => $this->path, 'validator' => $this->validator, 'name_filer_length' => $this->name_filer_length));
            $opt1 = $this->uploadifive->opt ? $this->uploadifive->opt->to_array() : array();
            $opt = array('multi' => new Zend\Json\Expr($this->multiple ? 1 : 0), 'width' => '160px', 'fileObjName' => $this->name, 'dnd' => new Zend\Json\Expr(0), 'buttonText' => $this->view->translate('form_element_file_uploadifive_button_text' . ($this->multiple ? '_multiple' : '')), 'uploadScript' => $this->view->url(array('controller' => 'x', 'action' => 'upload')), 'onUploadComplete' => new Zend\Json\Expr('function(file, text) {
					var t = $(this);
					if (typeof text != "string") text = "";
					if (text.slice(0, 3) == "ok|") {
						var v = text.slice(3);
						var file_data = window.uploadifive_data(v, file.queueItem);
						file_data.queueItem.find(".filename").html(v);
						file_data.queueItem.find(".image img").attr("src", "' . $this->url . '/" + v + "?" + Math.random() * 10000);
						file_data.queueItem.data("file", file_data);
					}
					else if (text.length && file.queueItem) {
						var info = text.replace("|", ", ");
						file.queueItem.find(".fileinfo").html(" - " + info);
						file.queueItem.find(".image").remove();
						var file_1 = file.queueItem.data("file");
						delete file_1["name"];
						file_1.name = "";
						window.setTimeout(function() {
							file.queueItem.find(".close").click();
						}, 800);
					}
					else {
						file.queueItem.find(".image img").attr("src", "' . $this->url . '/" + file.name + "?" + Math.random() * 10000);
					}
					var filename = file.queueItem.find(".filename").html();
					if (file.queueItem.find(".fileinfo").html().indexOf("Completed") !== -1) file.queueItem.find(".fileinfo").html(filename.length ? " / <a target=\\"_blank\\" href=\\"' . $this->url . '/" + filename + "\\">' . $this->view->translate('control_download') . '</a>" : "");
					window.uploadifive_update(t.parent().parent());
					' . @$opt1['customUpload'] . '
				}'), 'onSelect' => $this->multiple ? null : new Zend\Json\Expr('function(file) {
					var data = this.data("uploadifive");
					$(this).parent().parent().find("#' . $this->view->escape($this->name) . '_delete").remove();
					if (data.queue.count > 1) {
						var first = data.queueEl.find(".uploadifive-queue-item:first");
						if (first.length) {
							var file = first.data("file");
							if (file) data.removeQueueItem(file, true);
						}
					}
					' . @$opt1['customSelect'] . '
				}'), 'onCancel' => new Zend\Json\Expr('function() {
					var parent = $(this).parent().parent();
					window.setTimeout(function() {
						' . ($this->multiple ? '' : 'parent.append("<input type=\\"hidden\\" value=\\"' . $this->view->escape($this->value) . '\\" name=\\"' . $this->view->escape($this->name) . '_delete\\" id=\\"' . $this->view->escape($this->name) . '_delete\\" />");') . '
						window.uploadifive_update(parent);
					}, 800);
					' . @$opt1['customCancel'] . '
				}'), 'onInit' => new Zend\Json\Expr('function() {
					var t = $(this);
					var parent = t.parent().parent();
					var old = parent.find("input[type=hidden]:first").val();
					parent.find(".e-form-element-file-value").remove();
					if (old) {
						var files = old.split(",");
						for (k in files) {
							if (files[k].length) {
								var data = this.data("uploadifive");
								var file = window.uploadifive_data(files[k]);
								data.addQueueItem(file);
								file.queueItem.find(".progress").hide();
								data.uploadComplete(null, file, false);
							}
						}
					}
					if (parent.find("input[type=hidden]:first").length == 0) t.after("<input type=\\"hidden\\" name=\\"" + t.attr("name") + "\\" value=\\"\\" />");
					window.uploadifive_update(parent);
					' . @$opt1['customInit'] . '
				}'));
            if ($this->uploadifive->opt) {
                unset($opt1['customSelect']);
                unset($opt1['customUpload']);
                unset($opt1['customInit']);
                unset($opt1['customCancel']);
                $opt = array_merge($opt, $opt1);
            }
            $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/uploadifive/jquery.uploadifive.js')->append_inline('js', 'if (typeof window.uploadifive_update == "undefined") window.uploadifive_update = function(o) {
	var val = [];
	o.find(".uploadifive-queue-item").each(function() {
		var file = $(this).data("file");
		if (file && (typeof file.skip == "undefined" || !file.skip)) val.push(file.name);
	});
	o.find("input[type=hidden]:first").val(val.join(","));

};
if (typeof window.uploadifive_data == "undefined") window.uploadifive_data = function(name, item) {
	return {
		name: name,
		xhr: { responseText: "" },
		queueItem: item,
		complete: true
	};
};
$("input[type=file][name=\'' . $this->name . ($this->multiple && !$this->uploadifive ? '[]' : '') . '\']").uploadifive(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');');
            if ($this->uploadifive->css) {
                $this->view->messify->append('css', '/' . DIR_KERNEL . '/ctl/uploadifive/uploadifive.css');
            }
        }
        return parent::render();
    }
function print_datetime_element($params)
{
    if (empty($params['classes'])) {
        $params['classes'] = array('datetime_input');
    } else {
        $params['classes'][] = 'datetime_input';
    }
    $element = new form_element_input($params);
    echo $element->get_html();
}
Пример #10
0
    public function render()
    {
        if ($this->ui) {
            $opt = array();
            if ($this->ui->opt) {
                $opt = array_merge($opt, $this->ui->opt->to_array());
            }
            $opt['source'] = new Zend\Json\Expr('function(request, response) {
	$.ajax({
		url: "/x/autocomplete/model/' . $this->fetch->model . ($this->fetch->method ? '/method/' . $this->fetch->method : '') . ($this->fetch->param ? '/param/' . $this->fetch->param : '') . '/term/" + encodeURIComponent(request.term),
		dataType: "json",
		success: function(data) {
			response(data);
		}
	});
}');
            $opt['select'] = new Zend\Json\Expr('function(event, ui) {
	$("input[name=\'' . $this->name . '_fake\']").val(ui.item.label);
	$("input[name=\'' . $this->name . '\']").val(ui.item.value);
	$("input[name=\'' . $this->name . '\']").data("was_selected", true);
	return false;
}');
            $opt['change'] = new Zend\Json\Expr('function(event, ui) {
	if (!$("input[name=\'' . $this->name . '\']").data("was_selected")) {
		$("input[name=\'' . $this->name . '_fake\']").val("");
		$("input[name=\'' . $this->name . '\']").val("");
	}
	return false;
}');
            $opt['create'] = new Zend\Json\Expr('function(event, ui) {
	var val = $("input[name=\'' . $this->name . '\']").val();
	if (val && String(val).length) $.ajax({
		url: "/x/autocomplete/action/card/model/' . $this->fetch->model . ($this->fetch->method ? '/method/' . $this->fetch->method : '') . ($this->fetch->param ? '/param/' . $this->fetch->param : '') . '/value/" + encodeURIComponent(val),
		dataType: "json",
		success: function(data) {
			if (data && String(data.label).length) {
				$("input[name=\'' . $this->name . '_fake\']").val(data.label);
			}
			else {
				$("input[name=\'' . $this->name . '_fake\']").val("");
				$("input[name=\'' . $this->name . '\']").val("");
			}
		}
	});
	return false;
}');
            $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.core.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.widget.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.position.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.menu.js')->append('js', '/' . DIR_KERNEL . '/ctl/ui/ui/jquery.ui.autocomplete.js')->append_inline('js', '$("input[name=\'' . $this->name . '_fake\']").autocomplete(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');$("input[name=\'' . $this->name . '_fake\']").focus(function() {
										$("input[name=\'' . $this->name . '\']").data("was_selected", false);
									});')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.core.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.theme.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.menu.css')->append('css', '/' . DIR_KERNEL . '/ctl/ui/themes/' . $this->ui->theme . '/jquery.ui.autocomplete.css');
        }
        return parent::render();
    }
Пример #11
0
 public function render()
 {
     $opt = array('type' => $this->point, 'url' => $this->url);
     $this->view->messify->append('js', '/' . DIR_KERNEL . '/ctl/point/point.js')->append_inline('js', '$("input[name=\'' . $this->name . '\']").point(' . Zend\Json\Json::encode($opt, false, array('enableJsonExprFinder' => true)) . ');');
     return parent::render();
 }
Пример #12
0
 public function __construct($name, $param = array())
 {
     parent::__construct($name, $param);
     $this->type = 'password';
 }