当前位置: 首页>>代码示例>>PHP>>正文


PHP low_flatten_results函数代码示例

本文整理汇总了PHP中low_flatten_results函数的典型用法代码示例。如果您正苦于以下问题:PHP low_flatten_results函数的具体用法?PHP low_flatten_results怎么用?PHP low_flatten_results使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了low_flatten_results函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: settings

 /**
  * Settings
  *
  * @access     public
  * @param      array
  * @return     array
  */
 public function settings()
 {
     // -------------------------------------------
     // Get member groups with access to CP
     // -------------------------------------------
     $query = ee()->db->select('group_id, group_title')->from('member_groups')->where('can_access_cp', 'y')->order_by('group_title')->get();
     $groups = low_flatten_results($query->result_array(), 'group_title', 'group_id');
     // -------------------------------------------
     // Return list of groups
     // -------------------------------------------
     return array('can_create_sets' => array('ms', $groups, $this->default_settings['can_create_sets']));
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:19,代码来源:ext.low_reorder.php

示例2: display_input

 /**
  * Display input field for regular user
  *
  * @access     public
  * @param      int       $var_id        The id of the variable
  * @param      string    $var_data      The value of the variable
  * @param      array     $var_settings  The settings of the variable
  * @return     string
  */
 function display_input($var_id, $var_data, $var_settings)
 {
     // Keep track of all LR Sets
     static $sets;
     // Get them if not existing
     if (!$sets) {
         $query = $this->EE->db->select('set_id, set_label')->from('low_reorder_sets')->where('site_id', $this->EE->config->item('site_id'))->order_by('set_label', 'asc')->get();
         $sets = low_flatten_results($query->result_array(), 'set_label', 'set_id');
     }
     // Prepend empty option
     $options = array('' => '--') + $sets;
     // Return select element
     return form_dropdown("var[{$var_id}]", $options, $var_data);
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:23,代码来源:vt.low_reorder_vt.php

示例3: filter

 /**
  * Allows for category groups filtering: (1|2|3) && (4|5|6)
  *
  * @access     public
  * @return     void
  */
 public function filter($entry_ids)
 {
     // --------------------------------------
     // See if there are groups present, with correct values
     // --------------------------------------
     $groups = array_filter($this->params->get_prefixed('category:'), 'low_param_is_numeric');
     // --------------------------------------
     // Bail out if there are no groups
     // --------------------------------------
     if (empty($groups)) {
         return $entry_ids;
     }
     // --------------------------------------
     // Log it
     // --------------------------------------
     $this->_log('Applying ' . __CLASS__);
     // --------------------------------------
     // Loop through groups, compose SQL
     // --------------------------------------
     foreach ($groups as $key => $val) {
         // Prep the value
         $val = $this->params->prep($key, $val);
         // Get the parameter
         list($ids, $in) = low_explode_param($val);
         // Match all?
         $all = (bool) strpos($val, '&');
         // One query per group
         ee()->db->select('entry_id')->from('category_posts')->{$in ? 'where_in' : 'where_not_in'}('cat_id', $ids);
         // Limit by already existing ids
         if ($entry_ids) {
             ee()->db->where_in('entry_id', $entry_ids);
         }
         // Do the having-trick to account for *all* given entry ids
         if ($in && $all) {
             ee()->db->select('COUNT(*) AS num')->group_by('entry_id')->having('num', count($ids));
         }
         // Execute query
         $query = ee()->db->get();
         // And get the entry ids
         $entry_ids = low_flatten_results($query->result_array(), 'entry_id');
         $entry_ids = array_unique($entry_ids);
         // Bail out if there aren't any matches
         if (is_array($entry_ids) && empty($entry_ids)) {
             break;
         }
     }
     return $entry_ids;
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:54,代码来源:lsf.categories.php

示例4: display_settings

 /**
  * Display settings sub-form for this variable type
  *
  * @param	mixed	$var_id			The id of the variable: 'new' or numeric
  * @param	array	$var_settings	The settings of the variable
  * @return	array
  */
 function display_settings($var_id, $var_settings)
 {
     // -------------------------------------
     //  Init return value
     // -------------------------------------
     $r = array();
     // -------------------------------------
     //  Check current value from settings
     // -------------------------------------
     $folders = $this->get_setting('folders', $var_settings);
     // -------------------------------------
     //  Get all folders
     // -------------------------------------
     $all_folders = low_flatten_results($this->_get_upload_preferences(), 'name', 'id');
     // -------------------------------------
     //  Build options setting
     // -------------------------------------
     $r[] = array($this->setting_label(lang('file_folders')), form_multiselect($this->input_name('folders', TRUE), $all_folders, $folders));
     // -------------------------------------
     //  Build setting: Allow uploads?
     // -------------------------------------
     $upload_folders = array('0' => lang('no_uploads')) + $all_folders;
     $upload = $this->get_setting('upload', $var_settings);
     $overwrite = $this->get_setting('overwrite', $var_settings) == 'y';
     $r[] = array($this->setting_label(lang('upload_folder'), lang('upload_folder_help')), form_dropdown($this->input_name('upload'), $upload_folders, $upload, 'id="low-select-upload-folder"') . '<label class="low-checkbox low-inline" id="low-overwrite-files">' . form_checkbox($this->input_name('overwrite'), 'y', $overwrite) . lang('overwrite_existing_files_label') . '</label>');
     // -------------------------------------
     //  Build setting: multiple?
     // -------------------------------------
     $multiple = $this->get_setting('multiple', $var_settings) == 'y';
     $r[] = array($this->setting_label(lang('allow_multiple_files')), '<label class="low-checkbox">' . form_checkbox($this->input_name('multiple'), 'y', $multiple, 'class="low-allow-multiple"') . lang('allow_multiple_files_label') . '</label>');
     // -------------------------------------
     //  Build setting: separator
     // -------------------------------------
     $separator = $this->get_setting('separator', $var_settings);
     $r[] = array($this->setting_label(lang('separator_character')), $this->separator_select($separator));
     // -------------------------------------
     //  Build setting: multi interface
     // -------------------------------------
     $multi_interface = $this->get_setting('multi_interface', $var_settings);
     $r[] = array($this->setting_label(lang('multi_interface')), $this->interface_select($multi_interface, array('drag-list-thumbs' => lang('drag-list-thumbs'))));
     // -------------------------------------
     //  Return output
     // -------------------------------------
     return $r;
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:52,代码来源:vt.low_select_files.php

示例5: _v20b1

 /**
  * Update routines for version 2.0b1
  *
  * @access      private
  * @return      void
  */
 private function _v20b1()
 {
     // --------------------------------------
     // Install new tables
     // --------------------------------------
     ee()->low_reorder_set_model->install();
     ee()->low_reorder_order_model->install();
     // --------------------------------------
     // Get all current records from settings
     // --------------------------------------
     $query = ee()->db->get('low_reorder_settings');
     $rows = $query->result_array();
     // Return if no settings exist
     if (!empty($rows)) {
         // Upgrading from EE1
         if (!isset($rows[0]['channel_id'])) {
             foreach ($rows as &$r) {
                 $r['channel_id'] = $r['weblog_id'];
             }
         }
         // --------------------------------------
         // Get Field, Channel and Status details
         // --------------------------------------
         // Fields
         $query = ee()->db->select('field_id, site_id, field_name, field_label, field_instructions')->from('channel_fields')->where_in('field_id', low_flatten_results($rows, 'field_id'))->get();
         $fields = low_associate_results($query->result_array(), 'field_id');
         // Channels
         $query = ee()->db->select('channel_id, channel_name, channel_title, cat_group')->from('channels')->where_in('channel_id', low_flatten_results($rows, 'channel_id'))->get();
         $channels = low_associate_results($query->result_array(), 'channel_id');
         // Statuses
         $query = ee()->db->select('status_id, status')->from('statuses')->get();
         $statuses = low_flatten_results($query->result_array(), 'status', 'status_id');
         // --------------------------------------
         // Loop through rows and populate new table
         // --------------------------------------
         foreach ($rows as $row) {
             // Skip non-existent channels or fields
             if (!(isset($channels[$row['channel_id']]) && isset($fields[$row['field_id']]))) {
                 continue;
             }
             // Shortcut to related channel and field
             $channel = $channels[$row['channel_id']];
             $field = $fields[$row['field_id']];
             // Decode the settings
             $settings = decode_reorder_settings($row['settings']);
             // Initiate parameter array
             $params = array();
             // --------------------------------------
             // Set Channel parameter
             // --------------------------------------
             $params['channel'] = $channels[$row['channel_id']]['channel_name'];
             // --------------------------------------
             // Set Category parameter
             // --------------------------------------
             if (!empty($settings['categories'])) {
                 $params['category'] = implode('|', array_filter($settings['categories']));
             }
             // --------------------------------------
             // Set Status parameter
             // --------------------------------------
             if (!empty($settings['statuses'])) {
                 $tmp = array();
                 foreach ($settings['statuses'] as $status_id) {
                     $tmp[] = $statuses[$status_id];
                 }
                 $params['status'] = implode('|', array_unique($tmp));
                 unset($tmp);
             }
             // --------------------------------------
             // Set Show Expired parameter
             // --------------------------------------
             if (!empty($settings['show_expired']) && ($settings['show_expired'] == 'y' or $settings['show_expired'] === TRUE)) {
                 $params['show_expired'] = 'yes';
             }
             // --------------------------------------
             // Set Show Future Entries parameter
             // --------------------------------------
             if (!empty($settings['show_future']) && ($settings['show_future'] == 'y' or $settings['show_future'] === TRUE)) {
                 $params['show_future_entries'] = 'yes';
             }
             // --------------------------------------
             // Get permissions from settings
             // --------------------------------------
             $permissions = !empty($settings['permissions']) ? low_array_encode($settings['permissions']) : '';
             // --------------------------------------
             // Set Category Option value
             // --------------------------------------
             $cat_option = $settings['category_options'];
             // --------------------------------------
             // Set Category Groups value, if option is 'one'
             // --------------------------------------
             if ($cat_option == 'one' && $channel['cat_group']) {
                 $cat_groups = low_linearize(explode('|', $channel['cat_group']));
             } else {
//.........这里部分代码省略.........
开发者ID:kentonquatman,项目名称:iofa,代码行数:101,代码来源:upd.low_reorder.php

示例6: display_input

 /**
  * Display input field for regular user
  *
  * @param	int		$var_id			The id of the variable
  * @param	string	$var_data		The value of the variable
  * @param	array	$var_settings	The settings of the variable
  * @return	string
  */
 public function display_input($var_id, $var_data, $var_settings)
 {
     // -------------------------------------
     //  Prep options
     // -------------------------------------
     $settings = array();
     foreach ($this->default_settings as $key => $val) {
         $settings[$key] = $this->get_setting($key, $var_settings);
     }
     // -------------------------------------
     //  Prep current data
     // -------------------------------------
     $current = explode($this->separators[$settings['separator']], $var_data);
     $now = ee()->localize->now;
     // -------------------------------------
     //  Get entries
     // -------------------------------------
     ee()->db->select(array('t.entry_id', 't.title'))->from('channel_titles AS t');
     // Filter out future entries
     if ($settings['show_future'] != 'y') {
         ee()->db->where('t.entry_date <=', $now);
     }
     // Filter out expired entries
     if ($settings['show_expired'] != 'y') {
         ee()->db->where("(t.expiration_date > {$now} OR t.expiration_date = 0)");
     }
     // Filter by channel
     if ($filtered_channels = array_filter((array) $settings['channels'])) {
         ee()->db->where_in('t.channel_id', $filtered_channels);
     }
     // Filter by category
     if ($filtered_categories = array_filter((array) $settings['categories'])) {
         ee()->db->join('category_posts AS cp', 't.entry_id = cp.entry_id');
         ee()->db->where_in('cp.cat_id', $filtered_categories);
     }
     // Filter by status
     if ($filtered_statuses = array_filter((array) $settings['statuses'])) {
         ee()->db->where_in('t.status', $filtered_statuses);
     }
     // Order by custom order
     ee()->db->order_by($settings['orderby'], $settings['sort']);
     // Limit entries
     if ($settings['limit']) {
         ee()->db->limit($settings['limit']);
     }
     $query = ee()->db->get();
     $entries = low_flatten_results($query->result_array(), 'title', 'entry_id');
     // -------------------------------------
     //  Create interface
     // -------------------------------------
     if ($settings['multiple'] == 'y' && $settings['multi_interface'] == 'drag-list') {
         $r = $this->drag_lists($var_id, $entries, $current);
     } else {
         $r = $this->select_element($var_id, $entries, $current, $settings['multiple'] == 'y');
     }
     // -------------------------------------
     //  Return select element
     // -------------------------------------
     return $r;
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:68,代码来源:vt.low_select_entries.php

示例7: filter

 /**
  * Allows for tag filtering: (1|2|3) && (4|5|6)
  *
  * @access     public
  * @return     void
  */
 public function filter($entry_ids)
 {
     // -------------------------------------------
     // Make sure addons-library is loaded
     // -------------------------------------------
     ee()->load->library('addons');
     // -------------------------------------------
     // Solspace Tag or DevDemon Tagger?
     // -------------------------------------------
     if (ee()->addons->is_package('tag')) {
         $tables = array('tag_tags', 'tag_entries');
     } elseif (ee()->addons->is_package('tagger')) {
         $tables = array('tagger', 'tagger_links');
     }
     // --------------------------------------
     // See if there are tag params present
     // --------------------------------------
     $tag_names = $this->params->get_prefixed('tag_name');
     $tag_ids = $this->params->get_prefixed('tag_id');
     // --------------------------------------
     // Bail out if there are no tags
     // --------------------------------------
     if (empty($tables) || empty($tag_names) && empty($tag_ids)) {
         return $entry_ids;
     }
     // --------------------------------------
     // Log it
     // --------------------------------------
     $this->_log('Applying ' . __CLASS__);
     // -------------------------------------------
     // Check tag names and convert to tag IDs
     // -------------------------------------------
     if ($tag_names) {
         $unique_tags = array();
         foreach ($tag_names as $key => $val) {
             // Get the tags
             list($tags, $in) = low_explode_param($val);
             $unique_tags = array_merge($unique_tags, $tags);
         }
         // Remove duplicates and convert
         $unique_tags = array_unique($unique_tags);
         $unique_tags = array_map(array($this, '_convert_tag'), $unique_tags);
         // Get IDs for unique tags
         $query = ee()->db->select('tag_id, tag_name')->from($tables[0])->where_in('site_id', $this->params->site_ids())->where_in('tag_name', $unique_tags)->get();
         // clean up
         unset($unique_tags);
         // Get tag map: [tag name] => tag_id
         $tag_map = low_flatten_results($query->result_array(), 'tag_id', 'tag_name');
         // Now, loop through original tags thing and convert to tag IDs
         foreach ($tag_names as $key => $val) {
             // Initiate tag ids
             $ids = array();
             // Read parameter value
             list($tags, $in) = low_explode_param($val);
             // Loop through tags and map them to IDs
             foreach ($tags as $tag) {
                 $tag = $this->_convert_tag($tag);
                 if (isset($tag_map[$tag])) {
                     $ids[] = $tag_map[$tag];
                 }
             }
             if ($ids) {
                 // Check separator and implode back to parameter
                 $sep = strpos($val, '&') === FALSE ? '|' : '&';
                 $str = implode($sep, $ids);
                 // Add negator back
                 if (!$in) {
                     $str = 'not ' . $ids;
                 }
                 // Add final parameter string to IDs
                 $tag_ids[$key] = $str;
             }
         }
     }
     // --------------------------------------
     // Get channel IDs before starting the query
     // --------------------------------------
     $channel_ids = ee()->low_search_collection_model->get_channel_ids($this->params->get('collection'));
     // --------------------------------------
     // Loop through groups, compose SQL
     // --------------------------------------
     foreach ($tag_ids as $key => $val) {
         // Prep the value
         $val = $this->params->prep($key, $val);
         // Get the parameter
         list($ids, $in) = low_explode_param($val);
         // Match all?
         $all = (bool) strpos($val, '&');
         // One query per group
         ee()->db->distinct()->select('entry_id')->from($tables[1])->where_in('site_id', $this->params->site_ids())->{$in ? 'where_in' : 'where_not_in'}('tag_id', $ids);
         // Limit by already existing ids
         if ($entry_ids) {
             ee()->db->where_in('entry_id', $entry_ids);
         }
//.........这里部分代码省略.........
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:lsf.tags.php

示例8: get_oldest_index

 /**
  * Get oldest index for given collection or all collections
  *
  * @access      public
  * @param       int
  * @param       array
  * @return      void
  */
 public function get_oldest_index($collection_id = FALSE)
 {
     ee()->db->select('collection_id, MIN(index_date) AS index_date')->from($this->table())->where('site_id', $this->site_id)->group_by('collection_id');
     // Limit by given collection
     if ($collection_id) {
         ee()->db->where('collection_id', $collection_id);
     }
     $query = ee()->db->get();
     // Return array of collection_id => index_date
     return low_flatten_results($query->result_array(), 'index_date', 'collection_id');
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:19,代码来源:low_search_index_model.php

示例9: results

 /**
  * Modify a row for a search result for this filter
  */
 public function results($rows)
 {
     // -------------------------------------------
     // Shortcut to prefix
     // -------------------------------------------
     $pfx = ee()->low_search_settings->prefix;
     // -------------------------------------------
     // Prep collection info
     // -------------------------------------------
     if (!$this->_collections && $this->_results) {
         $col_ids = low_flatten_results($this->_results, 'collection_id');
         $col_ids = array_unique($col_ids);
         $this->_collections = ee()->low_search_collection_model->get_by_id($col_ids);
     }
     // -------------------------------------------
     // Loop through results and do yer thing
     // -------------------------------------------
     foreach ($rows as &$row) {
         // Get score for this entry
         $row[$pfx . 'score'] = $this->_get_score($row['entry_id']);
         // Add collection info to row
         foreach ($this->_get_collection_info($row['entry_id']) as $key => $val) {
             $row[$pfx . $key] = $val;
         }
     }
     // -------------------------------------------
     // No excerpt var in tagdata? No need to proceed.
     // -------------------------------------------
     if (strpos(ee()->TMPL->tagdata, $pfx . 'excerpt') === FALSE) {
         return $rows;
     }
     // -------------------------------------------
     // Load typography lib
     // -------------------------------------------
     ee()->load->library('typography');
     // -------------------------------------------
     // Get all entry ids we're working with
     // -------------------------------------------
     $entry_ids = low_flatten_results($rows, 'entry_id');
     // -------------------------------------------
     // Loop through results and add the excerpt
     // -------------------------------------------
     foreach ($rows as &$row) {
         // Get excerpt ID, the field ID to use as excerpt; 0 for title
         $eid = $this->_get_excerpt_id($row);
         // Skip if no valid excerpt ID is found
         if ($eid === FALSE) {
             continue;
         }
         // Get string and format for excerpt
         $str = $eid == '0' || !isset($row['field_id_' . $eid]) ? $row['title'] : $row['field_id_' . $eid];
         $fmt = $eid == '0' || !isset($row['field_fmt_' . $eid]) ? 'xhtml' : $row['field_fmt_' . $eid];
         // -------------------------------------------
         // 'low_search_excerpt' hook
         // - change the excerpt for an entry
         // -------------------------------------------
         if (ee()->extensions->active_hook('low_search_excerpt') === TRUE) {
             $str = ee()->extensions->call('low_search_excerpt', $entry_ids, $row, $eid);
             // Check return value
             if (is_array($str) && count($str) == 2) {
                 // Set excerpt string to first item in array
                 list($str, $skip) = $str;
                 // If second item in return value, skip native creation of excerpt
                 if ($skip === TRUE) {
                     $row[$pfx . 'excerpt'] = $str;
                     continue;
                 }
             }
         }
         // Overwrite empty excerpt with formatted one
         $row[$pfx . 'excerpt'] = $this->_create_excerpt($str, $fmt);
         // Highlight keywords if we have 'em
         if ($this->_keywords) {
             $row[$pfx . 'excerpt'] = $this->_highlight($row[$pfx . 'excerpt']);
             if (ee()->low_search_settings->get('title_hilite') == 'y') {
                 $row['title'] = $this->_highlight($row['title']);
             }
         }
     }
     return $rows;
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:84,代码来源:lsf.keywords.php

示例10: _filter_entry_ids

 /**
  * Filter the set's entry ids according to parameters
  *
  * @access     private
  * @return     void
  */
 private function _filter_entry_ids()
 {
     // Set/Cat key
     $key = $this->set_id . '-' . $this->cat_id;
     // Get entries from cache
     $entries = array_filter((array) low_get_cache(LOW_REORDER_PACKAGE, 'entry_ids'));
     if (!isset($entries[$key])) {
         // Log to template
         $this->_log('Getting ordered entry_ids from database');
         // Add channel_id and entry_id as parameter
         $params = $this->set['parameters'];
         $params['channel_id'] = implode('|', $this->set['channels']);
         $params['entry_id'] = implode('|', $this->entry_ids);
         // Fetch from DB
         $filtered = low_flatten_results($this->get_entries($params, FALSE), 'entry_id');
         // Intersect to preserve the order
         $filtered = array_filter(array_intersect($this->entry_ids, $filtered));
         $filtered = array_values($filtered);
         // Add to cache
         $entries[$key] = $filtered;
         low_set_cache(LOW_REORDER_PACKAGE, 'entry_ids', $entries);
         // Clean up
         unset($filtered);
     } else {
         // Log to template
         $this->_log('Getting ordered entry_ids from cache');
     }
     // Set the working entry ids to the filtered ones
     $this->entry_ids = $entries[$key];
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:36,代码来源:mod.low_reorder.php

示例11: flatten_results

 /**
  * Takes a DB result set, returns 'flat' array with key => val
  *
  * @param	array	$result_set		array with arrays (1 per result)
  * @param	string	$key			key value for flat array
  * @param	string	$val			value value for flat array
  * @return	array
  */
 protected function flatten_results($result_set, $key, $val)
 {
     return low_flatten_results($result_set, $val, $key);
 }
开发者ID:thomasvandoren,项目名称:teentix-site,代码行数:12,代码来源:Low_variables_type.php

示例12: build

 /**
  * Build collection index
  *
  * @access      protected
  * @return      array
  */
 public function build($collection_id = FALSE, $entry_ids = FALSE, $start = FALSE)
 {
     // --------------------------------------
     // Check for collection_id or entry_id
     // --------------------------------------
     $collection_id = $collection_id !== FALSE ? $collection_id : ee()->input->get_post('collection_id');
     $entry_ids = $entry_ids !== FALSE ? $entry_ids : ee()->input->get_post('entry_id');
     // --------------------------------------
     // Either collection_id or entry_id or both must be given
     // --------------------------------------
     if (!($collection_id || $entry_ids)) {
         show_error(ee()->lang->line('not_authorized'));
     }
     // --------------------------------------
     // Start building query to get collection details
     // --------------------------------------
     ee()->db->select('lsc.collection_id, lsc.channel_id, lsc.settings, lsc.site_id');
     ee()->db->from('low_search_collections lsc');
     // --------------------------------------
     // If there's a collection id, limit query by that one
     // --------------------------------------
     if ($collection_id) {
         ee()->db->where('lsc.collection_id', $collection_id);
     }
     // --------------------------------------
     // If there's an entry_id, limit query by those
     // --------------------------------------
     if ($entry_ids) {
         // Force array
         if (!is_array($entry_ids)) {
             $entry_ids = preg_split('/\\D+/', $entry_ids);
         }
         // Get collections for given entries
         ee()->db->select('GROUP_CONCAT(ct.entry_id) AS entries');
         ee()->db->join('channel_titles ct', 'lsc.channel_id = ct.channel_id');
         ee()->db->where_in('entry_id', $entry_ids);
         ee()->db->group_by('lsc.collection_id');
     }
     // --------------------------------------
     // Execute query and get results. Bail out if none
     // --------------------------------------
     if (!($collections = ee()->db->get()->result_array())) {
         return FALSE;
     }
     $collections = low_associate_results($collections, 'collection_id');
     $channel_ids = array_unique(low_flatten_results($collections, 'channel_id'));
     // --------------------------------------
     // Get batch size
     // --------------------------------------
     $batch_size = ee()->low_search_settings->get('batch_size');
     // --------------------------------------
     // Get total number of entries that need to be indexed
     // --------------------------------------
     if ($entry_ids) {
         $num_entries = count($entry_ids);
     } else {
         ee()->db->where_in('channel_id', $channel_ids);
         $num_entries = ee()->db->count_all_results('channel_titles');
     }
     // --------------------------------------
     // Get weighted field settings only, keep track of field ids
     // --------------------------------------
     $fields = array();
     $entries = array();
     foreach ($collections as &$col) {
         $col['settings'] = array_filter(low_search_decode($col['settings'], FALSE));
         // Add field ids to fields array
         $fields = array_merge($fields, array_keys($col['settings']));
         if (isset($col['entries'])) {
             foreach (explode(',', $col['entries']) as $eid) {
                 $entries[$eid][] = $col['collection_id'];
             }
         }
     }
     // Get rid of duplicate field ids
     $fields = array_unique($fields);
     sort($fields);
     // --------------------------------------
     // Let an extension take over?
     // --------------------------------------
     if (ee()->extensions->active_hook('low_search_get_index_entries') === TRUE) {
         $index_entries = ee()->extensions->call('low_search_get_index_entries', $fields, $channel_ids, $entry_ids, $start, $batch_size);
     } else {
         // --------------------------------------
         // Create select list
         // --------------------------------------
         $select = array('t.entry_id', 't.channel_id');
         foreach ($fields as $field_id) {
             // Skip non-numeric settings
             if (!is_numeric($field_id)) {
                 continue;
             }
             $select[] = $field_id == '0' ? 't.title AS field_id_0' : 'd.field_id_' . $field_id;
         }
//.........这里部分代码省略.........
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:Low_search_index.php

示例13: filter

 /**
  * Allows for search:title="foo|bar" parameter
  *
  * @access     private
  * @return     void
  */
 public function filter($entry_ids)
 {
     // --------------------------------------
     // Check if search:title is there
     // --------------------------------------
     $params = $this->params->get_prefixed($this->_pfx, TRUE);
     // --------------------------------------
     // Don't do anything if nothing's there
     // --------------------------------------
     if (empty($params)) {
         return $entry_ids;
     }
     // --------------------------------------
     // Log it
     // --------------------------------------
     $this->_log('Applying ' . __CLASS__);
     // --------------------------------------
     // Set channel IDs
     // --------------------------------------
     $this->_channel_ids = ee()->low_search_collection_model->get_channel_ids($this->params->get('collection'));
     // --------------------------------------
     // Loop through search filters and prep queries accordingly
     // --------------------------------------
     $queries = array();
     foreach ($params as $key => $val) {
         // Make sure value is prepped correctly with exact/exclude/require_all values
         $val = $this->params->prep($this->_pfx . $key, $val);
         // Search channel title
         if ($key == 'title') {
             // Title search
             $queries['channel_titles'][] = $this->_get_where('title', $val);
         } elseif (strpos($key, ':')) {
             list($field_name, $col_name) = explode(':', $key, 2);
             // Skip invalid fields
             if (!($field_id = $this->_get_field_id($field_name))) {
                 continue;
             }
             $table = FALSE;
             // Make sure it's an omelette!
             if ($this->_is_grid_field($field_name) && ($col_id = $this->_get_grid_col_id($field_id, $col_name))) {
                 $table = 'channel_grid_field_' . $field_id;
                 $field = 'col_id_' . $col_id;
             } elseif ($this->_is_matrix_field($field_id) && ($col_id = $this->_get_matrix_col_id($field_id, $col_name))) {
                 $table = 'matrix_data';
                 $field = 'col_id_' . $col_id;
             }
             if ($table) {
                 $queries[$table][] = $this->_get_where($field, $val);
             }
         } elseif ($field_id = $this->_get_field_id($key)) {
             // Regular fields
             $queries['channel_data'][] = $this->_get_where('field_id_' . $field_id, $val);
         }
         // Don't set it
         $this->params->forget[] = $this->_pfx . $key;
     }
     // --------------------------------------
     // Where now contains a list of clauses
     // --------------------------------------
     if (empty($queries)) {
         return $entry_ids;
     }
     // --------------------------------------
     // Query the lot!
     // --------------------------------------
     foreach ($queries as $table => $wheres) {
         // Start this query
         ee()->db->distinct()->select('entry_id')->from($table);
         // Add wheres
         foreach ($wheres as $sql) {
             ee()->db->where($sql);
         }
         // Limit by given entry ids?
         if (!empty($entry_ids)) {
             ee()->db->where_in('entry_id', $entry_ids);
         }
         // Limit only for non-grid tables
         if (in_array($table, array('channel_titles', 'channel_data'))) {
             // Limit by channel
             if ($this->_channel_ids) {
                 ee()->db->where_in('channel_id', $this->_channel_ids);
             }
             // Limit by site
             if ($site_ids = $this->params->site_ids()) {
                 ee()->db->where_in('site_id', $site_ids);
             }
         }
         // Execute!
         $query = ee()->db->get();
         // Get entry IDs
         $entry_ids = low_flatten_results($query->result_array(), 'entry_id');
         $entry_ids = array_unique($entry_ids);
         // Return immediately when no results are there
         if (empty($entry_ids)) {
//.........这里部分代码省略.........
开发者ID:realfluid,项目名称:umbaugh,代码行数:101,代码来源:lsf.field_search.php

示例14: _get_cols

 /**
  * Get array of column ids for given Grid or Matrix field
  *
  * @access      private
  * @param       int
  * @param       string
  * @return      array
  */
 private function _get_cols($id, $table = 'grid_columns')
 {
     static $cols = array();
     if (!isset($cols[$table][$id])) {
         $query = ee()->db->select('col_id')->from($table)->where('field_id', $id)->where('col_search', 'y')->get();
         $cols[$table][$id] = low_flatten_results($query->result_array(), 'col_id');
     }
     return $cols[$table][$id];
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:17,代码来源:mcp.low_search.php

示例15: _display_field

 /**
  * Display field in publish form or Matrix cell
  *
  * @param	string	Current value for field
  * @return	string	HTML containing input field
  */
 private function _display_field($data = '', $cell = FALSE)
 {
     // -------------------------------------
     //  What's the field name?
     // -------------------------------------
     $field_name = $cell ? $this->cell_name : $this->field_name;
     // -------------------------------------
     //  We need groups!
     // -------------------------------------
     if (empty($this->settings['lv_ft_groups'])) {
         return lang('no_variable_group_selected');
     }
     // -------------------------------------
     //  Get all variable groups
     // -------------------------------------
     if (!($groups = low_get_cache($this->package, 'groups'))) {
         $query = ee()->db->select('group_id, group_label')->from('low_variable_groups')->where('site_id', ee()->config->item('site_id'))->order_by('group_order')->get();
         $groups = low_flatten_results($query->result_array(), 'group_label', 'group_id');
         if (!$groups) {
             $groups = array();
         }
         $groups += array('0' => lang('ungrouped'));
         low_set_cache($this->package, 'groups', $groups);
     }
     // -------------------------------------
     //  Get variables from groups
     // -------------------------------------
     $query = ee()->db->select('ee.variable_name, low.variable_label, low.group_id')->from('global_variables ee')->join('low_variables low', 'ee.variable_id = low.variable_id')->where('ee.site_id', ee()->config->item('site_id'))->where_in('low.group_id', $this->settings['lv_ft_groups'])->where('low.early_parsing', 'n')->where('low.is_hidden', 'n')->order_by('low.variable_order', 'asc')->get();
     // Initiate arrays to get vars by
     $unordered_vars = $vars = array();
     // Loop through found vars and group by group label
     foreach ($query->result_array() as $row) {
         $unordered_vars[$row['group_id']][$row['variable_name']] = $row['variable_label'];
     }
     // Loop through groups (which are in the right order)
     // and group the vars by group label to easily create optgroups and such
     foreach ($groups as $group_id => $group_label) {
         if (isset($unordered_vars[$group_id])) {
             $vars[$group_label] = $unordered_vars[$group_id];
         }
     }
     // Reduce to 1 dimensional array
     if (count($vars) === 1) {
         $vars = $vars[key($vars)];
     }
     // clean up
     unset($unordered_vars);
     // -------------------------------------
     //  Multiple?
     // -------------------------------------
     if (@$this->settings['lv_ft_multiple'] == 'y') {
         // Init arrays for checkboxes
         $boxes = array();
         $data = explode("\n", $data);
         // Loop thru vars and create checkbox in a label
         foreach ($vars as $key => $val) {
             if (is_array($val)) {
                 $boxes[] = "<div style=\"margin:1em 0 .5em\"><strong>{$key}</strong></div>";
                 foreach ($val as $k => $v) {
                     $boxes[] = $this->_box($field_name, $k, in_array($k, $data), $v);
                 }
             } else {
                 $boxes[] = $this->_box($field_name, $key, in_array($key, $data), $val);
             }
         }
         // return string of checkboxes
         return implode("\n", $boxes);
     } else {
         $vars = array('' => '--') + $vars;
         return form_dropdown($field_name, $vars, $data);
     }
 }
开发者ID:kentonquatman,项目名称:iofa,代码行数:78,代码来源:ft.low_variables.php


注:本文中的low_flatten_results函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。