本文整理汇总了PHP中FlexicontentFields::getSearchFields方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::getSearchFields方法的具体用法?PHP FlexicontentFields::getSearchFields怎么用?PHP FlexicontentFields::getSearchFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::getSearchFields方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: countrows
/**
* count the rows
*
* @access public
* @return void
* @since 1.0
*/
function countrows()
{
$start_microtime = microtime(true);
// Check for request forgeries
//JRequest::checkToken() or jexit( 'Invalid Token' );
//$params = JComponentHelper::getParams( 'com_flexicontent' );
@ob_end_clean();
$indexer = JRequest::getVar('indexer', 'advanced');
$rebuildmode = JRequest::getVar('rebuildmode', '');
$session = JFactory::getSession();
// Retrieve fields, that are assigned as (advanced/basic) searchable/filterable
if ($rebuildmode == 'quick' && $indexer == 'advanced') {
$nse_fields = FlexicontentFields::getSearchFields('id', $indexer, null, null, $_load_params = false, 0, $search_type = 'non-search');
$nsp_fields = FlexicontentFields::getSearchFields('id', $indexer, null, null, $_load_params = false, 0, $search_type = 'dirty-nosupport');
$session->set($indexer . '_nse_fields', $nse_fields, 'flexicontent');
$session->set($indexer . '_nsp_fields', $nsp_fields, 'flexicontent');
$fields = FlexicontentFields::getSearchFields('id', $indexer, null, null, $_load_params = true, 0, $search_type = 'dirty-search');
} else {
$fields = FlexicontentFields::getSearchFields('id', $indexer, null, null, $_load_params = true, 0, $search_type = 'all-search');
}
// Get the field ids of the searchable fields
$fieldids = array_keys($fields);
// Get ids of searchable and ids of item having values for these fields
$itemsmodel = $this->getModel('items');
// Get items model to call needed methods
$itemids = $itemsmodel->getFieldsItems($fieldids);
// Get the items ids that have value for any of the searchable fields
// Set item ids into session to avoid recalculation ...
$session->set($indexer . '_items_to_index', $itemids, 'flexicontent');
// Set field information into session to avoid recalculation ...
$session->set($indexer . '_fields', $fields, 'flexicontent');
echo 'success';
//echo count($fieldids)*count($itemids).'|';
// WARNING: json_encode will output object if given an array with gaps in the indexing
//echo '|'.json_encode($itemids);
//echo '|'.json_encode($fieldids);
echo '|' . count($itemids);
echo '|' . count($fieldids);
$elapsed_microseconds = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10;
$session->set($indexer . '_total_runtime', $elapsed_microseconds, 'flexicontent');
exit;
}
示例2: onContentSearch
//.........这里部分代码省略.........
}
// Type based seach, get a single content type (first one, if more than 1 were given ...)
if ($type_based_search && !empty($contenttypes)) {
$single_contenttype = reset($contenttypes);
$contenttypes = array($single_contenttype);
} else {
$single_contenttype = false;
}
// *************************************
// Text Search Fields of the search form
// *************************************
if (!$txtmode) {
$txtflds = array();
$fields_text = array();
} else {
$txtflds = '';
if ($show_txtfields) {
if ($show_txtfields == 1) {
$txtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('searchable', '') : '';
} else {
$txtflds = $params->get('txtflds', '');
}
}
// Sanitize them
$txtflds = preg_replace("/[\"'\\\\]/u", "", $txtflds);
$txtflds = array_unique(preg_split("/\\s*,\\s*/u", $txtflds));
if (!strlen($txtflds[0])) {
unset($txtflds[0]);
}
// Create a comma list of them
$txtflds_list = count($txtflds) ? "'" . implode("','", $txtflds) . "'" : '';
// Retrieve field properties/parameters, verifying the support to be used as Text Search Fields
// This will return all supported fields if field limiting list is empty
$fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', $txtflds_list, $contenttypes, $load_params = true, 0, 'search');
if (empty($fields_text)) {
// all entries of field limiting list were invalid , get ALL
if (!empty($contenttypes)) {
$fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', null, $contenttypes, $load_params = true, 0, 'search');
} else {
$fields_text = array();
}
}
}
// ********************************
// Filter Fields of the search form
// ********************************
// Get them from type configuration or from search menu item
$filtflds = '';
if ($show_filters) {
if ($show_filters == 1) {
$filtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('filters', '') : '';
} else {
$filtflds = $params->get('filtflds', '');
}
}
// Sanitize them
$filtflds = preg_replace("/[\"'\\\\]/u", "", $filtflds);
$filtflds = array_unique(preg_split("/\\s*,\\s*/u", $filtflds));
if (!strlen($filtflds[0])) {
unset($filtflds[0]);
}
// Create a comma list of them
$filtflds_list = count($filtflds) ? "'" . implode("','", $filtflds) . "'" : '';
// Retrieve field properties/parameters, verifying the support to be used as Filter Fields
// This will return all supported fields if field limiting list is empty
if (count($filtflds)) {
示例3: display
//.........这里部分代码省略.........
}
// Type based seach, get a single content type (first one, if more than 1 were given ...)
if ($type_based_search && !empty($contenttypes)) {
$single_contenttype = reset($contenttypes);
$contenttypes = array($single_contenttype);
} else {
$single_contenttype = false;
}
// *************************************
// Text Search Fields of the search form
// *************************************
if (!$txtmode) {
$txtflds = array();
$fields_text = array();
} else {
$txtflds = '';
if ($show_txtfields) {
if ($show_txtfields == 1) {
$txtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('searchable', '') : '';
} else {
$txtflds = $params->get('txtflds', '');
}
}
// Sanitize them
$txtflds = preg_replace("/[\"'\\\\]/u", "", $txtflds);
$txtflds = array_unique(preg_split("/\\s*,\\s*/u", $txtflds));
if (!strlen($txtflds[0])) {
unset($txtflds[0]);
}
// Create a comma list of them
$txtflds_list = count($txtflds) ? "'" . implode("','", $txtflds) . "'" : '';
// Retrieve field properties/parameters, verifying the support to be used as Text Search Fields
// This will return all supported fields if field limiting list is empty
$fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', $txtflds_list, $contenttypes, $load_params = true, 0, 'search');
if (empty($fields_text)) {
// all entries of field limiting list were invalid , get ALL
if (!empty($contenttypes)) {
$fields_text = FlexicontentFields::getSearchFields($key = 'id', $indexer = 'advanced', null, $contenttypes, $load_params = true, 0, 'search');
} else {
$fields_text = array();
}
}
}
// ********************************
// Filter Fields of the search form
// ********************************
// Get them from type configuration or from search menu item
$filtflds = '';
if ($show_filters) {
if ($show_filters == 1) {
$filtflds = $single_contenttype ? $typeData[$single_contenttype]->params->get('filters', '') : '';
} else {
$filtflds = $params->get('filtflds', '');
}
}
// Sanitize them
$filtflds = preg_replace("/[\"'\\\\]/u", "", $filtflds);
$filtflds = array_unique(preg_split("/\\s*,\\s*/u", $filtflds));
if (!strlen($filtflds[0])) {
unset($filtflds[0]);
}
// Create a comma list of them
$filtflds_list = count($filtflds) ? "'" . implode("','", $filtflds) . "'" : '';
// Retrieve field properties/parameters, verifying the support to be used as Filter Fields
// This will return all supported fields if field limiting list is empty
if (count($filtflds)) {
示例4: purge
/**
* Method to empty search indexes
*
* @access public
* @return null
* @since 1.0
*/
function purge($del_fieldids = null)
{
$app = JFactory::getApplication();
$db = JFactory::getDBO();
// ******************************
// Empty Common text-search index
// ******************************
if (empty($del_fieldids)) {
$query = "TRUNCATE TABLE `#__flexicontent_advsearch_index`;";
} else {
$del_fieldids_list = implode(',', $del_fieldids);
$query = "DELETE FROM #__flexicontent_advsearch_index WHERE field_id IN (" . $del_fieldids_list . ")";
}
$db->setQuery($query);
$db->execute();
// **********************
// Empty per field TABLES
// **********************
$filterables = FlexicontentFields::getSearchFields('id', $indexer = 'advanced', null, null, $_load_params = true, 0, $search_type = 'filter');
$filterables = array_keys($filterables);
$filterables = array_flip($filterables);
$tbl_prefix = $app->getCfg('dbprefix') . 'flexicontent_advsearch_index_field_';
$query = "SELECT TABLE_NAME\n\t\t\tFROM INFORMATION_SCHEMA.TABLES\n\t\t\tWHERE TABLE_NAME LIKE '" . $tbl_prefix . "%'\n\t\t\t";
$db->setQuery($query);
$tbl_names = $db->loadColumn();
foreach ($tbl_names as $tbl_name) {
$_field_id = str_replace($tbl_prefix, '', $tbl_name);
// Drop the table of no longer filterable field
if (!isset($filterables[$_field_id])) {
$db->setQuery('DROP TABLE IF EXISTS ' . $tbl_name);
} else {
if (empty($del_fieldids) || isset($del_fieldids[$_field_id])) {
//$db->setQuery( 'DROP TABLE IF EXISTS '.$tbl_name );
$db->setQuery('TRUNCATE TABLE ' . $tbl_name);
}
}
$db->execute();
}
// VERIFY all search tables exist
$tbl_names_flipped = array_flip($tbl_names);
foreach ($filterables as $_field_id => $_ignored) {
$tbl_name = $app->getCfg('dbprefix') . 'flexicontent_advsearch_index_field_' . $_field_id;
$query = '
CREATE TABLE IF NOT EXISTS `' . $tbl_name . '` (
`sid` int(11) NOT NULL auto_increment,
`field_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`extraid` int(11) NOT NULL,
`search_index` longtext NOT NULL,
`value_id` varchar(255) NULL,
PRIMARY KEY (`field_id`,`item_id`,`extraid`),
KEY `sid` (`sid`),
KEY `field_id` (`field_id`),
KEY `item_id` (`item_id`),
FULLTEXT `search_index` (`search_index`),
KEY `value_id` (`value_id`)
) ENGINE=MyISAM CHARACTER SET `utf8` COLLATE `utf8_general_ci`
';
$db->setQuery($query);
$db->execute();
}
}
示例5: saveFields
//.........这里部分代码省略.........
}
}
// Trigger plugin Event 'onBeforeSaveField'
if (!$field->iscore || isset($core_via_post[$field->name])) {
$field_type = $field->iscore ? 'core' : $field->field_type;
$result = FLEXIUtilities::call_FC_Field_Func($field_type, 'onBeforeSaveField', array(&$field, &$postdata[$field->name], &$files[$field->name], &$item));
if ($result === false) {
// Field requested to abort item saving
$this->setError(JText::sprintf('FLEXI_FIELD_VALUE_IS_INVALID', $field->label));
return 'abort';
}
// For CORE field get the modified data, which will be used for storing in DB (these will be re-bind later)
if (isset($core_via_post[$field->name])) {
$core_data_via_events[$field->name] = isset($postdata[$field->name][0]) ? $postdata[$field->name][0] : '';
// The validation may have skipped it !!
}
} else {
// Currently other CORE fields, these are skipped we will not call onBeforeSaveField() on them, neither rebind them
}
//$qindex[$field->name] = NULL;
//$result = FLEXIUtilities::call_FC_Field_Func($field_type, 'onBeforeSaveField', array( &$field, &$postdata[$field->name], &$files[$field->name], &$item, &$qindex[$field->name] ));
//if ($result===false) { ... }
// Get vstate property from the field object back to the data array ... in case it was modified, since some field may decide to prevent approval !
$data['vstate'] = $field->item_vstate;
}
//echo "<pre>"; print_r($postdata); echo "</pre>"; exit;
}
if ($print_logging_info) {
@($fc_run_times['fields_value_preparation'] = round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
}
// **********************
// Empty per field TABLES
// **********************
$filterables = FlexicontentFields::getSearchFields('id', $indexer = 'advanced', null, null, $_load_params = true, 0, $search_type = 'filter');
$filterables = array_keys($filterables);
$filterables = array_flip($filterables);
$tbl_prefix = $app->getCfg('dbprefix') . 'flexicontent_advsearch_index_field_';
$query = "SELECT TABLE_NAME\n\t\t\tFROM INFORMATION_SCHEMA.TABLES\n\t\t\tWHERE TABLE_NAME LIKE '" . $tbl_prefix . "%'\n\t\t\t";
$this->_db->setQuery($query);
$tbl_names = $this->_db->loadColumn();
foreach ($tbl_names as $tbl_name) {
$_field_id = str_replace($tbl_prefix, '', $tbl_name);
// Drop the table of no longer filterable field
if (!isset($filterables[$_field_id])) {
$this->_db->setQuery('DROP TABLE IF EXISTS ' . $tbl_name);
} else {
// Remove item's old advanced search index entries
$query = "DELETE FROM " . $tbl_name . " WHERE item_id=" . $item->id;
$this->_db->setQuery($query);
$this->_db->query();
}
}
// VERIFY all search tables exist
$tbl_names_flipped = array_flip($tbl_names);
foreach ($filterables as $_field_id => $_ignored) {
$tbl_name = $app->getCfg('dbprefix') . 'flexicontent_advsearch_index_field_' . $_field_id;
if (isset($tbl_names_flipped[$tbl_name])) {
continue;
}
$query = '
CREATE TABLE IF NOT EXISTS `' . $tbl_name . '` (
`sid` int(11) NOT NULL auto_increment,
`field_id` int(11) NOT NULL,
`item_id` int(11) NOT NULL,
`extraid` int(11) NOT NULL,
`search_index` longtext NOT NULL,
示例6: index
function index()
{
$start_microtime = microtime(true);
$session = JFactory::getSession();
$db = JFactory::getDBO();
// Test indexing with limited memory
//ini_set("memory_limit", "20M");
@ob_end_clean();
$search_prefix = JComponentHelper::getParams('com_flexicontent')->get('add_search_prefix') ? 'vvv' : '';
// SEARCH WORD Prefix
$indexer = JRequest::getVar('indexer', 'advanced');
$rebuildmode = JRequest::getVar('rebuildmode', '');
$items_per_call = JRequest::getVar('items_per_call', 20);
// Number of item to index per HTTP request
$itemcnt = JRequest::getVar('itemcnt', 0);
// Counter of items indexed so far, this is given via HTTP request
// TAKE CARE: this code depends on countrows() to set session variables
// Retrieve fields, that are assigned as (advanced/basic) searchable/filterable
if ($rebuildmode == 'quick' && $indexer == 'advanced') {
$nse_fields = $session->get($indexer . '_nse_fields', array(), 'flexicontent');
$nsp_fields = $session->get($indexer . '_nsp_fields', array(), 'flexicontent');
$fields = $session->get($indexer . '_fields', array(), 'flexicontent');
//echo 'fail|'; print_r(array_keys($fields)); exit;
// Get the field ids of the fields removed from searching
$del_fieldids = array_unique(array_merge(array_keys($nse_fields), array_keys($nsp_fields), array_keys($fields)));
} else {
$fields = $session->get($indexer . '_fields', array(), 'flexicontent');
//echo 'fail|'; print_r(array_keys($fields)); exit;
}
// Get the field ids of the searchable fields
$fieldids = array_keys($fields);
// Get fields that will have atomic search tables, (current for advanced index only)
if ($indexer == 'advanced') {
$filterables = FlexicontentFields::getSearchFields('id', $indexer, null, null, $_load_params = false, 0, $search_type = 'filter');
$filterables = array_keys($filterables);
$filterables = array_flip($filterables);
} else {
$filterables = array();
}
// Get items ids that have value for any of the searchable fields, but use session to avoid recalculation
$itemids = $session->get($indexer . '_items_to_index', array(), 'flexicontent');
$_fields = array();
foreach ($fields as $field_id => $field) {
// Clone field to avoid problems
$_fields[$field_id] = clone $field;
// Create field parameters if not already created
if (empty($_fields[$field_id]->parameters)) {
$_fields[$field_id]->parameters = new JRegistry($_fields[$field_id]->attribs);
}
}
$fields = $_fields;
// Get query size limit
$query = "SHOW VARIABLES LIKE 'max_allowed_packet'";
$db->setQuery($query);
$_dbvariable = $db->loadObject();
$max_allowed_packet = flexicontent_upload::parseByteLimit(@$_dbvariable->Value);
$max_allowed_packet = $max_allowed_packet ? $max_allowed_packet : 256 * 1024;
$query_lim = (int) (3 * $max_allowed_packet / 4);
//echo 'fail|'.$query_lim; exit;
// Get script max
$max_execution_time = ini_get("max_execution_time");
//echo 'fail|'.$max_execution_time; exit;
$query_count = 0;
$max_items_per_query = 100;
$max_items_per_query = $max_items_per_query > $items_per_call ? $items_per_call : $max_items_per_query;
$cnt = $itemcnt;
while ($cnt < count($itemids) && $cnt < $itemcnt + $items_per_call) {
$query_itemids = array_slice($itemids, $cnt, $max_items_per_query);
$cnt += $max_items_per_query;
// Item is not needed, later and only if field uses item replacements then it will be loaded
$item = null;
// Items language is needed to do (if needed) special per language handling
$lang_query = "SELECT id, language" . " FROM #__content AS i " . " WHERE id IN (" . implode(', ', $query_itemids) . ")";
$db->setQuery($lang_query);
$items_data = $db->loadObjectList('id');
if ($indexer == 'basic') {
$searchindex = array();
// Add all query itemids to searchindex array so that it will be cleared even if zero fields are indexed
foreach ($query_itemids as $query_itemid) {
$searchindex[$query_itemid] = array();
}
} else {
// This will hold the SQL inserting new advanced search records for multiple item/values
$ai_query_vals = array();
$ai_query_vals_f = array();
// Current for advanced index only
}
// For current item: Loop though all searchable fields according to their type
foreach ($fieldids as $fieldid) {
// Must SHALLOW clone because we will be setting some properties , e.g. 'ai_query_vals', that we do not
$field = clone $fields[$fieldid];
// Indicate multiple items per query
$field->item_id = 0;
$field->query_itemids = $query_itemids;
$field->items_data = $items_data;
// Includes item langyage, which may be used for special per language handling
// Indicate that the indexing fuction should retrieve the values
$values = null;
// Add values to advanced search index
$fieldname = $field->iscore ? 'core' : $field->field_type;
//.........这里部分代码省略.........