本文整理汇总了PHP中array_for_select函数的典型用法代码示例。如果您正苦于以下问题:PHP array_for_select函数的具体用法?PHP array_for_select怎么用?PHP array_for_select使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_for_select函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor method
*/
public function __construct()
{
parent::__construct();
// Load the required classes
$this->load->library('form_validation');
$this->load->model('navigation_m');
$this->load->model('pages/page_m');
$this->lang->load('navigation');
$this->template->append_js('module::navigation.js')->append_css('module::navigation.css');
// Get Navigation Groups
$this->template->groups = $this->navigation_m->get_groups();
$this->template->groups_select = array_for_select($this->template->groups, 'id', 'title');
$all_modules = $this->module_m->get_all(array('is_frontend' => true));
//only allow modules that user has permissions for
foreach ($all_modules as $module) {
if (in_array($module['slug'], $this->permissions) or $this->current_user->group == 'admin') {
$modules[] = $module;
}
}
$this->template->modules_select = array_for_select($modules, 'slug', 'name');
// Get Pages and create pages tree
$tree = array();
if ($pages = $this->page_m->get_all()) {
foreach ($pages as $page) {
$tree[$page->parent_id][] = $page;
}
}
unset($pages);
$this->template->pages_select = $tree;
// Set the validation rules for the navigation items
$this->form_validation->set_rules($this->validation_rules);
}
示例2: __construct
/**
* Constructor method
* @access public
* @return void
*/
public function __construct()
{
// Call the parent's contstructor
parent::__construct();
// Load the required classes
$this->load->library('form_validation');
$this->load->model('navigation_m');
$this->load->model('pages/pages_m');
$this->lang->load('navigation');
$this->template->set_partial('shortcuts', 'admin/partials/shortcuts');
$this->template->append_metadata(js('navigation.js', 'navigation'));
// Get Navigation Groups
$this->data->groups = $this->navigation_m->get_groups();
$this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
$modules = $this->module_m->get_all(array('is_frontend' => true));
$this->data->modules_select = array_for_select($modules, 'slug', 'name');
// Get Pages and create pages tree
$tree = array();
if ($pages = $this->pages_m->get_all()) {
foreach ($pages as $page) {
$tree[$page->parent_id][] = $page;
}
}
unset($pages);
$this->data->pages_select = $tree;
// Set the validation rules for the navigation items
$this->validation_rules = array(array('field' => 'title', 'label' => lang('nav_title_label'), 'rules' => 'trim|required|max_length[40]'), array('field' => 'link_type', 'label' => lang('nav_type_label'), 'rules' => 'trim|alpha'), array('field' => 'url', 'label' => lang('nav_url_label'), 'rules' => 'trim'), array('field' => 'uri', 'label' => lang('nav_uri_label'), 'rules' => 'trim'), array('field' => 'module_name', 'label' => lang('nav_module_label'), 'rules' => 'trim|alpha_dash'), array('field' => 'page_id', 'label' => lang('nav_page_label'), 'rules' => 'trim|numeric'), array('field' => 'navigation_group_id', 'label' => lang('nav_group_label'), 'rules' => 'trim|numeric|required'), array('field' => 'target', 'label' => lang('nav_target_label'), 'rules' => 'trim|max_length[10]'));
$this->form_validation->set_rules($this->validation_rules);
}
示例3: __construct
public function __construct()
{
parent::__construct();
// $this->load->model('enquiry/news_m');
// $this->data['trickers'] = $this->news_m->get_by(array('status' => 1),false,5);
$this->load->model('settings/setting_m');
$this->load->library('ion_auth');
$metadata = $this->setting_m->get();
$this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value');
}
示例4: __construct
public function __construct()
{
parent::__construct();
$this->load->library('grocery_CRUD');
$this->upload_path = '../assets/uploads/' . 'hotels';
$this->wrapper = 'gc_admin_wrapper';
$this->load->model('generic_model');
$this->load->helper('email');
$metadata = $this->db->get_where('settings', array('settings_status' => 1))->result();
$this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value', 'site_name');
}
示例5: __construct
/**
* Constructor method
*/
public function __construct()
{
parent::__construct();
// Load the required classes
$this->load->model('user_m');
$this->load->model('groups/group_m');
$this->load->helper('user');
$this->load->library('form_validation');
$this->lang->load('user');
$this->template->groups = $this->group_m->get_all();
$this->template->groups_select = array_for_select($this->template->groups, 'id', 'description');
}
示例6: __construct
public function __construct()
{
parent::__construct();
$this->load->library(array('ion_auth', 'form_validation'));
$this->load->helper(array('language', 'pagination', 'array'));
$this->load->model('blog_m');
if (!$this->ion_auth->logged_in()) {
// redirect them to the login page
redirect(ADMIN_URL . '/login', 'refresh');
}
$category = $this->blog_m->getData('post_category', array('status' => 'live'))->result_array();
$category = array_for_select($category, 'id', 'title');
$this->template->set_layout('default', 'admin')->set_partial('header', 'admin/partials/header')->set_partial('sidebar', 'admin/partials/sidebar')->set_partial('footer', 'admin/partials/footer')->set('category', $category);
}
示例7: __construct
function __construct()
{
parent::Admin_Controller();
$this->load->library('user_lib');
$this->load->model('users_m');
$this->load->helper('user');
$this->lang->load('user');
$this->data->roles = $this->permissions_m->get_roles();
$this->data->roles_select = array_for_select($this->data->roles, 'abbrev', 'title');
// Sidebar data
$this->data->inactive_user_count = $this->users_m->count_by('is_active', 0);
$this->data->active_user_count = $this->users_m->count_by('is_active', 1);
$this->template->set_partial('sidebar', 'admin/sidebar');
}
示例8: __construct
/**
* Constructor method
*/
public function __construct()
{
parent::__construct();
// Load the required classes
$this->load->model('user_m');
$this->load->model('groups/group_m');
$this->load->helper('user');
$this->load->library('form_validation');
$this->lang->load('user');
if ($this->current_user->group != 'admin') {
$this->template->groups = $this->group_m->where_not_in('name', 'admin')->get_all();
} else {
$this->template->groups = $this->group_m->get_all();
}
$this->template->groups_select = array_for_select($this->template->groups, 'id', 'description');
}
示例9: __construct
/**
* Constructor method
* @access public
* @return void
*/
public function __construct()
{
// Call the parent's constructor method
parent::Admin_Controller();
// Load the required classes
$this->load->model('users_m');
$this->load->model('groups/group_m');
$this->load->helper('user');
$this->load->library('form_validation');
$this->lang->load('user');
$this->data->groups = $this->group_m->get_all();
$this->data->groups_select = array_for_select($this->data->groups, 'id', 'description');
$this->template->set_partial('shortcuts', 'admin/partials/shortcuts');
}
示例10: __construct
/**
* Constructor method
* @access public
* @return void
*/
public function __construct()
{
// Call the parent's constructor method
parent::Admin_Controller();
// Load the required classes
$this->load->model('users_m');
$this->load->helper('user');
$this->load->library('form_validation');
$this->lang->load('user');
// Create the validation array
$this->validation_rules = array(array('field' => 'first_name', 'label' => lang('user_first_name_label'), 'rules' => 'required|alpha_dash'), array('field' => 'last_name', 'label' => lang('user_last_name_label'), 'rules' => 'required|surname'), array('field' => 'display_name', 'label' => lang('user_display_name'), 'rules' => 'required|alphanumeric|maxlength[50]'), array('field' => 'password', 'label' => lang('user_password_label'), 'rules' => 'min_length[6]|max_length[20]'), array('field' => 'confirm_password', 'label' => lang('user_password_confirm_label'), 'rules' => 'matches[password]'), array('field' => 'email', 'label' => lang('user_email_label'), 'rules' => 'required|valid_email'), array('field' => 'username', 'label' => lang('user_username'), 'rules' => 'required|alphanumeric|maxlength[20]'), array('field' => 'group', 'label' => lang('user_group_id_label'), 'rules' => 'required'), array('field' => 'active', 'label' => lang('user_active_label'), 'rules' => ''));
$this->data->roles = $this->permissions_m->get_roles();
$this->data->roles_select = array_for_select($this->data->roles, 'name', 'title');
// Sidebar data
$this->data->inactive_user_count = $this->users_m->count_by('active', 0);
$this->data->active_user_count = $this->users_m->count_by('active', 1);
$this->template->set_partial('sidebar', 'admin/sidebar');
}
示例11: __construct
function __construct()
{
parent::Admin_Controller();
$this->load->model('navigation_m');
$this->load->module_model('pages', 'pages_m');
$this->load->module_helper('pages', 'pages');
$this->load->helper('array');
// Get Navigation Groups
$this->data->groups = $this->navigation_m->getGroups();
$this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
$modules = $this->modules_m->getModules(array('is_frontend' => true));
$this->data->modules_select = array_for_select($modules, 'slug', 'name');
// Get Pages and create pages tree
$tree = array();
foreach ($this->pages_m->getPages() as $page) {
$tree[$page->parent][] = $page;
}
$this->data->pages_select = $tree;
}
示例12: __construct
public function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->language('language');
if (!$this->ion_auth->logged_in()) {
$this->session->set_flashdata('errorlogin', "You must log in!");
redirect('login');
}
$userdata = $this->ion_auth->user($this->session->userdata('user_id'))->row();
$this->data['uname'] = $userdata->first_name . ' ' . $userdata->last_name;
$this->data['uid'] = $userdata->id;
$this->data['uemail'] = $userdata->email;
$this->data['ucompany'] = $userdata->company;
$this->data['uphone'] = $userdata->phone;
$this->load->model('settings/setting_m');
$metadata = $this->setting_m->get();
$this->data['metadata'] = array_for_select($metadata, 'settings_name', 'settings_value');
$this->load->library('grocery_CRUD');
}
示例13: __construct
function __construct()
{
parent::Admin_Controller();
$this->load->model('navigation_m');
$this->load->model('pages/pages_m');
$this->load->helper('array');
$this->lang->load('navigation');
$this->template->set_partial('sidebar', 'admin/sidebar');
$this->template->append_metadata(js('navigation.js', 'navigation'));
// Get Navigation Groups
$this->data->groups = $this->navigation_m->get_groups();
$this->data->groups_select = array_for_select($this->data->groups, 'id', 'title');
$modules = $this->modules_m->getModules(array('is_frontend' => true));
$this->data->modules_select = array_for_select($modules, 'slug', 'name');
// Get Pages and create pages tree
$tree = array();
if ($pages = $this->pages_m->get_all()) {
foreach ($pages as $page) {
$tree[$page->parent_id][] = $page;
}
}
unset($pages);
$this->data->pages_select = $tree;
}
示例14: edit
/**
* Create the form for editing a widget instance
*
* @return void
*/
public function edit($id = 0)
{
if (!($id && ($widget = $this->widgets->get_instance($id)))) {
// @todo: set error
return false;
}
$data = array();
if ($input = $this->input->post()) {
$title = $input['title'];
$widget_id = $input['widget_id'];
$widget_area_id = $input['widget_area_id'];
$instance_id = $input['widget_instance_id'];
unset($input['title'], $input['widget_id'], $input['widget_area_id'], $input['widget_instance_id']);
$result = $this->widgets->edit_instance($instance_id, $title, $widget_area_id, $input);
if ($result['status'] === 'success') {
// Fire an event. A widget instance has been updated pass the widget instance id.
Events::trigger('widget_instance_updated', $instance_id);
$status = 'success';
$message = lang('success_label');
$area = $this->widgets->get_area($widget_area_id);
} else {
$status = 'error';
$message = $result['error'];
}
if ($this->input->is_ajax_request()) {
$data = array();
$status === 'success' and $data['messages'][$status] = $message;
$message = $this->load->view('admin/partials/notices', $data, true);
return $this->template->build_json(array('status' => $status, 'message' => $message, 'active' => isset($area) && $area ? '#area-' . $area->slug . ' header' : false));
}
if ($status === 'success') {
$this->session->set_flashdata($status, $message);
redirect('admins/widgets');
return;
}
$data['messages'][$status] = $message;
}
$this->db->order_by('`title`');
$data['widget_areas'] = $this->widgets->list_areas();
$data['widget_areas'] = array_for_select($data['widget_areas'], 'id', 'title');
$data['widget'] = $widget;
$data['form'] = $this->widgets->render_backend($widget->slug, isset($widget->options) ? $widget->options : array());
$this->template->build('admin/instances/form', $data);
}
示例15: edit
function edit($id = 0)
{
if (empty($id)) {
redirect('admin/pages');
}
// We use this controller property for a validation callback later on
$this->page_id = $id;
// Set data, if it exists
if (!($page = $this->pages_m->get($id))) {
$this->session->set_flashdata('error', $this->lang->line('pages_page_not_found_error'));
redirect('admin/pages/create');
}
$this->load->library('validation');
$this->validation->set_rules($this->rules);
$this->validation->set_fields();
// Auto-set data for the page if a post variable overrides it
foreach (array_keys($this->rules) as $field) {
if ($this->input->post($field) !== FALSE) {
$page->{$field} = $this->validation->{$field};
}
}
// Give validation a try, who knows, it just might work!
if ($this->validation->run()) {
// Run the update code with the POST data
$this->pages_m->update($id, $_POST);
// The slug has changed
if ($this->input->post('slug') != $this->input->post('old_slug')) {
$this->pages_m->reindex_descendants($id);
}
// Wipe cache for this model as the data has changed
$this->cache->delete_all('pages_m');
$this->session->set_flashdata('success', sprintf($this->lang->line('pages_edit_success'), $this->input->post('title')));
redirect('admin/pages');
}
// If a parent id was passed, fetch the parent details
if ($page->parent_id > 0) {
$parent_page = $this->pages_m->get($page->parent_id);
$parent_page->path = $this->pages_m->get_path_by_id($page->parent_id);
}
// Assign data for display
$this->data->page =& $page;
$this->data->parent_page =& $parent_page;
$page_layouts = $this->page_layouts_m->get_all();
$this->data->page_layouts = array_for_select($page_layouts, 'id', 'title');
// Get "roles" (like access levels)
//$this->data->roles = $this->permissions_m->get_roles();
//ksort($this->data->roles);
//$this->data->roles_select = array_for_select($this->data->roles, 'id', 'title');
// Load WYSIWYG editor
$this->template->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_metadata(js('codemirror/codemirror.js'))->append_metadata(js('form.js', 'pages'))->build('admin/form', $this->data);
}