function options_list($key = 'fuel_user_id', $val = 'display_name', $where = array(), $order = 'display_name') { if ($key == 'id') { $key = $this->table_name . '.fuel_user_id'; } if ($val == 'display_name') { $val = 'IF(display_name = "", fuel_users.email, display_name) AS name'; } $this->db->join('fuel_users', 'fuel_users.id = fuel_blog_users.fuel_user_id', 'left'); $return = parent::options_list($key, $val, $where, $order); return $return; }
function options_list($key = 'id', $val = 'name', $where = array(), $order = 'name') { $CI =& get_instance(); if ($key == 'id') { $key = $this->table_name . '.id'; } if ($val == 'name') { $val = 'CONCAT(first_name, " ", last_name) as name'; } if (!$CI->fuel_auth->is_super_admin()) { $this->db->where(array('super_admin' => 'no')); } $return = parent::options_list($key, $val, $where, $order); return $return; }
/** * Initializes the class with the parent model and field names * * @access public * @return array */ public function context_options_list() { $this->db->group_by('context'); $this->db->where('context != ""'); return parent::options_list('context', 'context'); }
/** * Overwritten: Allows for grouping of menu items with last paramter * * @access public * @param string The column to use for the value (optional) * @param string The column to use for the label (optional) * @param mixed An array or string containg the where paramters of a query (optional) * @param string The order by of the query. defaults to $val asc (optional) * @param boolean Determines whether it will group the options together based on the menu troup (optional) * @return array */ public function options_list($key = 'id', $val = 'label', $where = array(), $order = TRUE, $group = TRUE) { if (!empty($order) and is_bool($order)) { $this->db->order_by($val, 'asc'); } else { if (!empty($order) and is_string($order)) { if (strpos($order, ' ') === FALSE) { $order .= ' asc'; } $this->db->order_by($order); } } if ($group) { // need to turn this off to get the proper ordering $data = $this->find_all_array_assoc($key, $where); return $this->_group_options($data, $key, $val); } else { return parent::options_list($key, $val, $where, $order); } }
/** * Overwrites the parent option_list method * * @access public * @param string the name of the field to be used as the key (optional) * @param string the name of the filed to be used as the value (optional) * @param mixed the where condition to apply (optional) * @param mixed the order in which to return the results (optional) * @return array */ public function options_list($key = 'id', $val = 'name', $where = array(), $order = TRUE) { $this->db->join($this->_tables['fuel_categories'], $this->_tables['fuel_categories'] . '.id = ' . $this->_tables['fuel_tags'] . '.category_id', 'LEFT'); // if (empty($key)) $key = $this->_tables['fuel_categories'].'.id'; // if (empty($val)) $val = $this->_tables['fuel_categories'].'.name'; if (empty($key)) { $key = $this->_tables['fuel_tags'] . '.id'; } if (empty($val)) { $val = $this->_tables['fuel_tags'] . '.name'; } // needed to prevent ambiguity if (strpos($key, '.') === FALSE and strpos($key, '(') === FALSE) { $key = $this->_tables['fuel_tags'] . '.' . $key; } // needed to prevent ambiguity if (strpos($val, '.') === FALSE and strpos($val, '(') === FALSE) { $val = $this->_tables['fuel_tags'] . '.' . $val; } $options = parent::options_list($key, $val, $where, $order); return $options; }
public function options_list_with_views($where = array(), $dir_folder = '', $dir_filter = '^_(.*)|\\.html$', $order = TRUE, $recursive = TRUE) { $CI =& get_instance(); $CI->load->helper('directory'); $module_path = APPPATH; if (is_array($dir_folder)) { $module = key($dir_folder); $dir_folder = current($dir_folder); if (is_string($module)) { $module_path = MODULES_PATH . $module; } } $dir_folder = trim($dir_folder, '/'); $blocks_path = $module_path . '/views/_blocks/' . $dir_folder; // don't display blocks with preceding underscores or .html files' $block_files = directory_to_array($blocks_path, $recursive, '#' . $dir_filter . '#', FALSE, TRUE); $view_blocks = array(); foreach ($block_files as $block) { $view_blocks[$block] = $block; } // if a dir_folder exists, then we will look for any CMS blocks that may be prefixed with that dir_folder // (e.g. sections/left_block becomes just left_block) if (!empty($dir_folder) and empty($where)) { $where = 'name LIKE "' . $dir_folder . '/%"'; } $blocks = parent::options_list('name', 'name', $where, $order); // continue filter of cms blocks dir_folder is specified $cms_blocks = array(); if (!empty($dir_folder)) { $cms_blocks = array(); foreach ($blocks as $key => $val) { $key = preg_replace('#^' . $dir_folder . '/(.+)#', '$1', $key); $cms_blocks[$key] = $key; } } else { $cms_blocks = $blocks; } $blocks = array_merge($view_blocks, $cms_blocks); if ($order) { ksort($blocks); } return $blocks; }