本文整理汇总了PHP中Formo::splitby方法的典型用法代码示例。如果您正苦于以下问题:PHP Formo::splitby方法的具体用法?PHP Formo::splitby怎么用?PHP Formo::splitby使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Formo
的用法示例。
在下文中一共展示了Formo::splitby方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
public function check($group, $element = '')
{
$form = Formo::instance($this->formo_name);
if (is_object($form->{$group}) and get_class($form->{$group}) == 'Formo_Group') {
foreach (Formo::splitby($element) as $el) {
$form->{$group}->{$el}->checked = TRUE;
}
} else {
$form->{$group}->checked = TRUE;
}
}
示例2: add_info
public function add_info($info)
{
$info = Formo::quicktags($info);
foreach ($info as $k => $v) {
if ($k == 'source') {
$this->source = explode('::', $v);
} elseif ($k == 'data') {
$this->data = Formo::splitby($v);
} elseif ($k == 'mode') {
$this->mode = $v;
} else {
$this->{$k} = $v;
}
}
}
示例3: model
public function model($model, $method, $data = array(), $construct_data = NULL)
{
$this->models[] = array('model' => $model, 'method' => $method, 'data' => Formo::splitby($data), 'construct_data' => $construct_data);
}
示例4: validate_this
protected function validate_this()
{
$input = Input::instance();
$fname = isset($_FILES[$this->name . '_file']) ? $this->name . '_file' : $this->name;
$file = isset($_FILES[$fname]) ? $_FILES[$fname] : NULL;
$already_uploaded = $input->post($this->name . '_path') ? TRUE : FALSE;
$this->was_validated = TRUE;
if ($this->required and empty($file['name']) and !$already_uploaded) {
if ($already_uploaded and is_file($input->post($this->name . '_path'))) {
unlink($input->post($this->name . '_path'));
}
$this->error = $this->required_msg;
return $this->error;
} elseif (!$this->required and !$input->post($this->name) and empty($file['name'])) {
return;
} else {
$allowed_types = Formo::splitby($this->allowed_types);
$time = time();
// this means we're good with the file uploaded already
if ($already_uploaded === TRUE and !$file['name']) {
$full_path = $input->post($this->name . '_path');
$path = array_pop(explode('/', $full_path));
$file_name = $input->post($this->name);
} elseif ($file['name']) {
// delete old entry
if ($already_uploaded) {
$full_path = $input->post($this->name . '_path');
$path = array_pop(preg_split('/\\//', $full_path));
$file_name = $input->post($this->name);
if (is_file($full_path)) {
unlink($full_path);
}
}
// start validating
if (!upload::required($file)) {
return $this->error = Kohana::lang('formo.invalidfile');
}
if (!upload::size($file, array($this->max_size))) {
return $this->error = Kohana::lang('formo.too_large') . ' (' . $this->max_size . ')';
}
if (!upload::type($file, $allowed_types)) {
return $this->error = Kohana::lang('formo.invalid_type');
}
$full_path = upload::save($fname, $time . $file['name'], DOCROOT . $this->upload_path, 0777);
$path = array_pop(preg_split('/\\//', $full_path));
$file_name = $file['name'];
}
// fill $this->data with appropriate info
$this->data['orig_name'] = $file_name;
$this->data['file_name'] = end(preg_split('/\\//', $full_path));
$this->data['path'] = preg_replace('/\\/' . $this->data['file_name'] . '/', '', $full_path);
$this->data['full_path'] = $full_path;
$this->data['file_ext'] = strtolower(substr(strrchr($file_name, '.'), 1));
$this->data['file_type'] = reset(Kohana::config('mimes.' . $this->data['file_ext']));
$this->data['bytes'] = filesize($full_path);
$this->data['file_size'] = round(filesize($full_path) / 1024, 2);
$this->data['time'] = $time;
if ($isize = getimagesize($full_path)) {
$this->data['is_image'] = 1;
$this->data['image_width'] = $isize[0];
$this->data['image_height'] = $isize[1];
$this->data['image_size_str'] = $isize[3];
} else {
$this->data['is_image'] = 0;
$this->data['image_width'] = NULL;
$this->data['image_height'] = NULL;
$this->data['image_size_str'] = NULL;
}
$this->value = $this->data;
// create the extra stuff for saving past, accepted uploads and unvalidated forms
$this->type = 'text';
$this->_was_file = TRUE;
$this->add_class($this->file_link_class);
$this->value = $file_name;
$this->readOnly = 'readOnly';
$this->onClick = 'file_replace(\'' . $this->id . '\')';
$oldclose = $this->element_close;
$class = !empty($this->class) ? ' class="' . preg_replace('/ *' . $this->file_link_class . '/', '', $this->class) . '"' : '';
$this->str = '<input type="text" name="' . $this->name . '" value="' . $this->value . '"' . Formo::quicktagss($this->_find_tags()) . ' />' . '<script type="text/javascript">' . "\n" . 'function file_replace(id){' . "\n" . 'var txt = document.getElementById(id);' . "\n" . 'var file = document.getElementById(id+"_file");' . "\n" . 'txt.style.display = "none";' . "\n" . 'file.style.display = "inline";' . "\n" . '}' . "\n" . '</script>' . "\n" . '<input type="hidden" name="' . $this->name . '_path" id="' . $this->id . '_path" value="' . $full_path . '" />' . "\n" . '<input type="file" name="' . $this->name . '_file" id="' . $this->id . '_file"' . $class . ' style="display:none"/>' . "\n" . $oldclose;
}
}