public function getDefault($default = array()) { $default['id'] = $this->getId(); $default['name'] = $this->name; $default['placeholder'] = $this->placeholder; if (isset($this->type)) { $default['type'] = $this->type; } if (isset($this->defaultValue)) { $default['value'] = $this->defaultValue; } if (isset($this->value)) { $default['value'] = $this->value; } $default = copy_arr($this->validationRules(), $default); return $default; }
public function queryRows($begin, $end) { $this->result_mode = 'object'; $begin = $begin->format('Y-m-d H:i:s'); $end = $end->format('Y-m-d H:i:s'); if (isset($this->sql)) { $query_args = copy_arr($this->args); $query_args[] = $begin; $query_args[] = $end; $result = $this->query($this->fixPrefix($this->sql), $query_args); } else { $this->select('avg(' . $this->col . ') as value, ' . $this->groupby_col . ' as legend'); $this->group_by($this->groupby_col); if (isset($this->orderby_col)) { $this->order_by($this->orderby_col); } else { $this->order_by($this->groupby_col); } if ($this->where) { if (!is_array($this->where)) { $this->where = (array) $this->where; } $this->where[$this->timestamp_col . ' >= '] = $begin; $this->where[$this->timestamp_col . ' < '] = $end; } else { $this->where = array($this->timestamp_col . ' >= ' => $begin, $this->timestamp_col . ' < ' => $end); } $result = $this->get_all($this->where); } if (count($result)) { return array_map(function ($item) { return array($item->legend, $item->value); }, $result); } return array(); }
public function getJQValidationRules() { return array_reduce($this->rules, function ($ret, $r) { return copy_arr($r->toJQValidationRule(), $ret); }, array()); }
public function login() { #TODO: Fetch the logo from user's account $this->init_responsive(); $this->less('api/signin_css'); $data = array('logo' => 'signin-logo.png', 'welcome_message' => lang_f('<span>Welcome to</span>%s', 'WALDORF ASTORIA'), 'title' => 'Waldorf Astoria'); if ($this->input->get('preview') == 'true') { $this->render('api/signin', $data); return; } // TODO: Add regex validation $this->_param('serial', 'Serial'); $this->_param('gateway_ip', 'Gateway Ip', array('required', 'valid_ip')); $this->_param('gateway_port', 'Gateway port'); $this->_param('ip', 'ip', array('required', 'valid_ip')); $this->_param('mac', 'mac'); $this->_param('url', 'url'); // END if ($this->isValid()) { // First, store all the data into session $this->load->library('session'); $sessions = $this->input->get(); $this->session->set_userdata($sessions); $data = copy_arr($this->session->all_userdata(), $data); // Then add the login request $this->load->model('loginrequest_model'); $this->loginrequest_model->add($this->input->get()); // Then show the login page $this->render('api/signin', $data); } else { echo validation_errors(); //redirect(site_url('/')); } }