本文整理汇总了PHP中FlexicontentFields::_getCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::_getCategories方法的具体用法?PHP FlexicontentFields::_getCategories怎么用?PHP FlexicontentFields::_getCategories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::_getCategories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Method to bind fields to an items object
*
* @access private
* @return object
* @since 1.5
*/
static function &getFields(&$_items, $view = FLEXI_ITEMVIEW, $params = null, $aid = false, $use_tmpl = true)
{
static $expired_cleaned = false;
if (!$_items) {
return $_items;
}
if (!is_array($_items)) {
$items = array(&$_items);
} else {
$items =& $_items;
}
$user = JFactory::getUser();
$cparams = JComponentHelper::getParams('com_flexicontent');
$print_logging_info = $cparams->get('print_logging_info');
if ($print_logging_info) {
global $fc_run_times;
$start_microtime = microtime(true);
}
// Calculate access for current user if it was not given or if given access is invalid
if (FLEXI_J16GE) {
$aid = is_array($aid) ? $aid : JAccess::getAuthorisedViewLevels($user->id);
} else {
$aid = $aid !== false ? (int) $aid : (int) $user->get('aid');
}
// Apply cache to public (unlogged) users only
/*$apply_cache = !$user->id && FLEXI_CACHE;
if ($apply_cache) {
$itemcache = JFactory::getCache('com_flexicontent_items'); // Get Joomla Cache of '...items' Caching Group
$itemcache->setCaching(1); // Force cache ON
$itemcache->setLifeTime(FLEXI_CACHE_TIME); // Set expire time (default is 1 hour)
$filtercache = JFactory::getCache('com_flexicontent_filters'); // Get Joomla Cache of '...filters' Caching Group
$filtercache->setCaching(1); // Force cache ON
$filtercache->setLifeTime(FLEXI_CACHE_TIME); // Set expire time (default is 1 hour)
// Auto-clean expired item & filters cache, only done here once
if (FLEXI_GC && !$expired_cleaned) {
$itemcache->gc();
$filtercache->gc();
$expired_cleaned = true;
}
// ... now retrieved CACHED ... code removed ...
}*/
// @TODO : move to the constructor
// This is optimized regarding the use of SINGLE QUERY to retrieve the core item data
$vars['tags'] = FlexicontentFields::_getTags($items);
$vars['cats'] = FlexicontentFields::_getCategories($items);
$vars['favourites'] = FlexicontentFields::_getFavourites($items);
$vars['favoured'] = FlexicontentFields::_getFavoured($items);
$vars['authors'] = FlexicontentFields::_getAuthors($items);
$vars['modifiers'] = FlexicontentFields::_getModifiers($items);
$vars['typenames'] = FlexicontentFields::_getTypenames($items);
$vars['votes'] = FlexicontentFields::_getVotes($items);
$vars['custom'] = FlexicontentFields::_getCustomValues($items);
FlexicontentFields::getItemFields($items, $vars, $view, $aid);
if ($print_logging_info) {
@($fc_run_times['field_values_params'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
}
$_rendered = array();
if ($params) {
$always_create_fields_display = $cparams->get('always_create_fields_display', 0);
$flexiview = JRequest::getVar('view');
// CHECK if 'always_create_fields_display' enabled and create the display for all item's fields
// *** This should be normally set to ZERO (never), to avoid a serious performance penalty !!!
// 0: never, 1: always, 2: only in item view, 3: never unless in a template position, this effects function: renderPositions()
if ($always_create_fields_display == 1 || $always_create_fields_display == 2 && $flexiview == FLEXI_ITEMVIEW && $view == FLEXI_ITEMVIEW) {
$field_names = array();
foreach ($items as $i => $item) {
if ($items[$i]->fields) {
foreach ($items[$i]->fields as $field) {
$values = isset($items[$i]->fieldvalues[$field->id]) ? $items[$i]->fieldvalues[$field->id] : array();
$field = FlexicontentFields::renderField($items[$i], $field, $values, $method = 'display', $view);
$field_names[$field->name] = 1;
}
}
}
foreach ($field_names as $field_name => $_ignore) {
$_rendered['ALL'][$field_name] = 1;
}
}
// Render field positions
$items = FlexicontentFields::renderPositions($items, $view, $params, $use_tmpl, $_rendered);
}
return $items;
}
示例2: onContentSearch
//.........这里部分代码省略.........
case 'newest':
$order = 'i.created DESC';
break;
default:
$order = 'i.created DESC';
break;
}
// ****************************************************************************************
// Create JOIN clause and WHERE clause part for filtering by current (viewing) access level
// ****************************************************************************************
$joinaccess = '';
$andaccess = '';
$select_access = '';
// Extra access columns for main category and content type (item access will be added as 'access')
$select_access .= ', c.access as category_access, ty.access as type_access';
if (!$show_noauth) {
// User not allowed to LIST unauthorized items
if (FLEXI_J16GE) {
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$aid_list = implode(",", $aid_arr);
$andaccess .= ' AND ty.access IN (0,' . $aid_list . ')';
$andaccess .= ' AND c.access IN (0,' . $aid_list . ')';
$andaccess .= ' AND i.access IN (0,' . $aid_list . ')';
} else {
$aid = (int) $user->get('aid');
if (FLEXI_ACCESS) {
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gt ON ty.id = gt.axo AND gt.aco = "read" AND gt.axosection = "type"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gc ON c.id = gc.axo AND gc.aco = "read" AND gc.axosection = "category"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gi ON i.id = gi.axo AND gi.aco = "read" AND gi.axosection = "item"';
$andaccess .= ' AND (gt.aro IN ( ' . $user->gmid . ' ) OR ty.access <= ' . $aid . ')';
$andaccess .= ' AND (gc.aro IN ( ' . $user->gmid . ' ) OR c.access <= ' . $aid . ')';
$andaccess .= ' AND (gi.aro IN ( ' . $user->gmid . ' ) OR i.access <= ' . $aid . ')';
} else {
$andaccess .= ' AND ty.access <= ' . $aid;
$andaccess .= ' AND c.access <= ' . $aid;
$andaccess .= ' AND i.access <= ' . $aid;
}
}
$select_access .= ', 1 AS has_access';
} else {
// Access Flags for: content type, main category, item
if (FLEXI_J16GE) {
$aid_arr = JAccess::getAuthorisedViewLevels($user->id);
$aid_list = implode(",", $aid_arr);
$select_access .= ', ' . ' CASE WHEN ' . ' ty.access IN (' . $aid_list . ') AND ' . ' c.access IN (' . $aid_list . ') AND ' . ' i.access IN (' . $aid_list . ') ' . ' THEN 1 ELSE 0 END AS has_access';
} else {
$aid = (int) $user->get('aid');
if (FLEXI_ACCESS) {
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gt ON ty.id = gt.axo AND gt.aco = "read" AND gt.axosection = "type"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gc ON c.id = gc.axo AND gc.aco = "read" AND gc.axosection = "category"';
$joinaccess .= ' LEFT JOIN #__flexiaccess_acl AS gi ON i.id = gi.axo AND gi.aco = "read" AND gi.axosection = "item"';
$select_access .= ', ' . ' CASE WHEN ' . ' (gt.aro IN ( ' . $user->gmid . ' ) OR ty.access <= ' . (int) $aid . ') AND ' . ' (gc.aro IN ( ' . $user->gmid . ' ) OR c.access <= ' . (int) $aid . ') AND ' . ' (gi.aro IN ( ' . $user->gmid . ' ) OR i.access <= ' . (int) $aid . ') ' . ' THEN 1 ELSE 0 END AS has_access';
} else {
$select_access .= ', ' . ' CASE WHEN ' . ' (ty.access <= ' . (int) $aid . ') AND ' . ' ( c.access <= ' . (int) $aid . ') AND ' . ' ( i.access <= ' . (int) $aid . ') ' . ' THEN 1 ELSE 0 END AS has_access';
}
}
}
// **********************************************************************************************************************************************************
// Create WHERE clause part for filtering by current active language, and current selected contend types ( !! although this is possible via a filter too ...)
// **********************************************************************************************************************************************************
$andlang = '';
if ($app->isSite() && (FLEXI_FISH || FLEXI_J16GE && $app->getLanguageFilter()) && $filter_lang) {
$andlang .= ' AND ( i.language LIKE ' . $db->Quote($lang . '%') . ' OR i.language="*" ) ';
$andlang .= ' AND ( c.language LIKE ' . $db->Quote($lang . '%') . ' OR c.language="*" ) ';
}
// search articles
$results = array();
if ($limit > 0) {
$query = $db->getQuery(true);
$query->clear();
$query->select('' . ' i.id as id,' . ' i.title AS title,' . ' i.language AS language,' . ' i.metakey AS metakey,' . ' i.metadesc AS metadesc,' . ' i.modified AS created,' . ' t.name AS tagname,' . ' fir.value as field,' . ' i.access, ie.type_id,' . ' CONCAT(i.introtext, i.fulltext) AS text,' . ' CONCAT_WS( " / ", ' . $db->Quote(JText::_('FLEXICONTENT')) . ', c.title, i.title ) AS section,' . ' CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END AS slug,' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END AS catslug,' . ' "2" AS browsernav' . $select_access);
$query->from('#__content AS i ' . ' JOIN #__categories AS c ON i.catid = c.id' . ' JOIN #__flexicontent_items_ext AS ie ON i.id = ie.item_id' . ' JOIN #__flexicontent_types AS ty ON ie.type_id = ty.id' . ' LEFT JOIN #__flexicontent_fields_item_relations AS fir ON i.id = fir.item_id' . ' LEFT JOIN #__flexicontent_fields AS f ON fir.field_id = f.id' . ' LEFT JOIN #__flexicontent_tags_item_relations AS tir ON i.id = tir.itemid' . ' LEFT JOIN #__flexicontent_tags AS t ON tir.tid = t.id ' . $joinaccess);
$query->where(' (' . $where . ') ' . ' AND ie.type_id IN(' . $types . ') ' . ' AND i.state IN (1, -5) AND c.published = 1 ' . ' AND (i.publish_up = ' . $db->Quote($nullDate) . ' OR i.publish_up <= ' . $db->Quote($nowDate) . ') ' . ' AND (i.publish_down = ' . $db->Quote($nullDate) . ' OR i.publish_down >= ' . $db->Quote($nowDate) . ') ' . $andaccess . $andlang);
$query->group('i.id');
$query->order($order);
//echo "<pre style='white-space:normal!important;'>".$query."</pre>";
$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->getErrorMsg();
}
if ($list) {
$item_cats = FlexicontentFields::_getCategories($list);
foreach ($list as $key => $item) {
// echo $item->title." ".$item->tagname."<br/>"; // Before checking for noHTML
if (FLEXI_J16GE || $item->sectionid == FLEXI_SECTION) {
$item->categories = isset($item_cats[$item->id]) ? $item_cats[$item->id] : array();
// in case of item categories missing
$item->href = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->catslug, 0, $item));
} else {
$item->href = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catslug, $item->sectionid));
}
if (searchHelper::checkNoHTML($item, $searchText, array('title', 'metadesc', 'metakey', 'tagname', 'field', 'text'))) {
$results[$item->id] = $item;
}
}
}
}
return $results;
}
示例3: onContentSearch
//.........这里部分代码省略.........
$and_where_filters = count($filters_where) ? implode(" ", $filters_where) : '';
// ************************************************
// Set variables used by filters creation mechanism
// ************************************************
global $fc_searchview;
$fc_searchview['join_clauses'] = $join_clauses;
$fc_searchview['join_clauses_with_text'] = $join_clauses_with_text;
$fc_searchview['where_conf_only'] = $where_conf;
// WHERE of the view (mainly configuration dependent)
$fc_searchview['filters_where'] = $filters_where;
// WHERE of the filters
$fc_searchview['search'] = $text_where;
// WHERE for text search
$fc_searchview['params'] = $params;
// view's parameters
// *****************************************************************************************************
// Execute search query. NOTE this is skipped it if (a) no text-search and no (b) no filters are active
// *****************************************************************************************************
// Do not check for 'contentypes' this are based on configuration and not on form submitted data,
// considering contenttypes or other configuration based parameters, will return all items on initial search view display !
if (!count($filters_where) && !strlen($text)) {
return array();
}
$print_logging_info = $params->get('print_logging_info');
if ($print_logging_info) {
global $fc_run_times;
$start_microtime = microtime(true);
}
// *****************************************
// Overcome possible group concat limitation
// *****************************************
$query = "SET SESSION group_concat_max_len = 9999999";
$db->setQuery($query);
$db->execute();
// *************
// Get the items
// *************
$query = 'SELECT SQL_CALC_FOUND_ROWS i.id' . $orderby_col . ' FROM #__content AS i' . $join_clauses_with_text . $orderby_join . $joinaccess . $where_conf . $and_where_filters . ' GROUP BY i.id ' . $orderby;
//echo "Adv search plugin main SQL query: ".nl2br($query)."<br/><br/>";
// NOTE: The plugin will return a PRECONFIGURED limited number of results, the SEARCH VIEW to do the pagination, splicing (appropriately) the data returned by all search plugins
try {
// Get items, we use direct query because some extensions break the SQL_CALC_FOUND_ROWS, so let's bypass them (at this point it is OK)
// *** Usage of FOUND_ROWS() will fail when (e.g.) Joom!Fish or Falang are installed, in this case we will be forced to re-execute the query ...
// PLUS, we don't need Joom!Fish or Falang layer at --this-- STEP which may slow down the query considerably in large sites
$query_limited = $query . ' LIMIT ' . $search_limit . ' OFFSET 0';
$rows = flexicontent_db::directQuery($query_limited);
$item_ids = array();
foreach ($rows as $row) {
$item_ids[] = $row->id;
}
// Get current items total for pagination
$db->setQuery("SELECT FOUND_ROWS()");
$fc_searchview['view_total'] = $db->loadResult();
$app->setUserState('fc_view_total_' . $view, $fc_searchview['view_total']);
} catch (Exception $e) {
// Get items via normal joomla SQL layer
$db->setQuery(str_replace('SQL_CALC_FOUND_ROWS', '', $query), 0, $search_limit);
$item_ids = $db->loadColumn(0);
}
if (!count($item_ids)) {
return array();
}
// No items found
// *****************
// Get the item data
// *****************
$query_data = 'SELECT i.id, i.title AS title, i.created, i.id AS fc_item_id, i.access, ie.type_id, i.language' . (!$txtmode ? ', ie.search_index AS text' : ', GROUP_CONCAT(ts.search_index ORDER BY f.ordering ASC SEPARATOR \' \') AS text') . ', CASE WHEN CHAR_LENGTH(i.alias) THEN CONCAT_WS(\':\', i.id, i.alias) ELSE i.id END as slug' . ', CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug' . ', CONCAT_WS( " / ", ' . $db->Quote($searchFlexicontent) . ', c.title, i.title ) AS section' . $select_access . ' FROM #__content AS i' . $join_clauses . $join_textsearch . $join_textfields . ' WHERE i.id IN (' . implode(',', $item_ids) . ') ' . ' GROUP BY i.id ' . ' ORDER BY FIELD(i.id, ' . implode(',', $item_ids) . ')';
//echo nl2br($query)."<br/><br/>";
$db->setQuery($query_data);
$list = $db->loadObjectList();
if ($db->getErrorNum()) {
echo $db->getErrorMsg();
}
if ($print_logging_info) {
@($fc_run_times['search_query_runtime'] += round(1000000 * 10 * (microtime(true) - $start_microtime)) / 10);
}
// *************************************
// Create item links and other variables
// *************************************
//echo "<pre>"; print_r($list); echo "</pre>";
if ($list) {
if (count($list) >= $search_limit) {
$app->setUserState('fc_view_limit_max_' . $view, $search_limit);
}
$item_cats = FlexicontentFields::_getCategories($list);
foreach ($list as $key => $item) {
$item->text = preg_replace('/\\b' . $search_prefix . '/', '', $item->text);
$item->categories = isset($item_cats[$item->id]) ? $item_cats[$item->id] : array();
// in case of item categories missing
// If joomla article view is allowed allowed and then search view may optional create Joomla article links
if ($typeData[$item->type_id]->params->get('allow_jview', 0) && $typeData[$item->type_id]->params->get('search_jlinks', 1)) {
$item->href = JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->categoryslug, $item->language));
} else {
$item->href = JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug, 0, $item));
}
$item->browsernav = $browsernav;
}
}
return $list;
}
示例4: array
/**
* Method to fetch the fields from an item object
*
* @access private
* @return object
* @since 1.5
*/
static function &getItemFields(&$items, &$vars = null, $view = FLEXI_ITEMVIEW, $aid = false)
{
if (empty($items)) {
return;
}
static $type_fields = array();
$dispatcher = JDispatcher::getInstance();
$db = JFactory::getDBO();
$user = JFactory::getUser();
// This is optimized regarding the use of SINGLE QUERY to retrieve the core item data
if ($vars == null) {
$vars['tags'] = FlexicontentFields::_getTags($items, $view);
$vars['cats'] = FlexicontentFields::_getCategories($items, $view);
$vars['favourites'] = FlexicontentFields::_getFavourites($items, $view);
$vars['favoured'] = FlexicontentFields::_getFavoured($items, $view);
$vars['authors'] = FlexicontentFields::_getAuthors($items, $view);
$vars['modifiers'] = FlexicontentFields::_getModifiers($items, $view);
$vars['typenames'] = FlexicontentFields::_getTypenames($items, $view);
$vars['votes'] = FlexicontentFields::_getVotes($items, $view);
$vars['custom'] = FlexicontentFields::_getCustomValues($items, $view);
}
foreach ($items as $i => $item) {
if (!FLEXI_J16GE && $item->sectionid != FLEXI_SECTION) {
continue;
}
$item_id = $item->id;
$cats = isset($vars['cats'][$item_id]) ? $vars['cats'][$item_id] : array();
$tags = isset($vars['tags'][$item_id]) ? $vars['tags'][$item_id] : array();
$favourites = isset($vars['favourites'][$item_id]) ? $vars['favourites'][$item_id]->favs : 0;
$favoured = isset($vars['favoured'][$item_id]) ? $vars['favoured'][$item_id]->fav : 0;
$author = isset($vars['authors'][$item_id]) ? $vars['authors'][$item_id] : '';
$modifier = isset($vars['modifiers'][$item_id]) ? $vars['modifiers'][$item_id] : '';
$typename = isset($vars['typenames'][$item_id]) ? $vars['typenames'][$item_id] : '';
$vote = isset($vars['votes'][$item_id]) ? $vars['votes'][$item_id] : '';
$custom = isset($vars['custom'][$item_id]) ? $vars['custom'][$item_id] : array();
// ONCE per Content Item Type
if (!isset($type_fields[$item->type_id])) {
// Field's has_access flag
$aid_arr = is_array($aid) ? $aid : JAccess::getAuthorisedViewLevels($user->id);
$aid_list = implode(",", $aid_arr);
$select_access = ', CASE WHEN fi.access IN (0,' . $aid_list . ') THEN 1 ELSE 0 END AS has_access';
$query = 'SELECT fi.*' . $select_access . ' FROM #__flexicontent_fields AS fi' . ' JOIN #__flexicontent_fields_type_relations AS ftrel ON ftrel.field_id = fi.id AND ftrel.type_id = ' . $item->type_id . ' WHERE fi.published = 1' . ' GROUP BY fi.id' . ' ORDER BY ftrel.ordering, fi.ordering, fi.name';
$db->setQuery($query);
$type_fields[$item->type_id] = $db->loadObjectList('name');
//echo "<pre>"; print_r( array_keys($type_fields[$item->type_id]) ); exit;
}
$item->fields = array();
if ($type_fields[$item->type_id]) {
foreach ($type_fields[$item->type_id] as $field_name => $field_data) {
$item->fields[$field_name] = clone $field_data;
}
}
$item->fields = $item->fields ? $item->fields : array();
if (!isset($item->parameters)) {
$item->parameters = new JRegistry($item->attribs);
}
$item->params = $item->parameters;
$item->text = $item->introtext . chr(13) . chr(13) . $item->fulltext;
$item->tags = $tags;
$item->cats = $cats;
$item->favs = $favourites;
$item->fav = $favoured;
$item->creator = @$author->alias ? $author->alias : (@$author->name ? $author->name : '');
$item->author =& $item->creator;
// An alias ... of creator
$item->modifier = @$modifier->name ? $modifier->name : $item->creator;
// If never modified, set modifier to be the creator
$item->modified = $item->modified != $db->getNulldate() ? $item->modified : $item->created;
// If never modified, set modification date to be the creation date
$item->cmail = @$author->email ? $author->email : '';
$item->cuname = @$author->username ? $author->username : '';
$item->mmail = @$modifier->email ? $modifier->email : $item->cmail;
$item->muname = @$modifier->muname ? $modifier->muname : $item->cuname;
$item->typename = @$typename->name ? $typename->name : JText::_('Article');
$item->vote = @$vote ? $vote : '';
// some aliases to much CORE field names
$item->categories =& $item->cats;
$item->favourites =& $item->favs;
$item->document_type =& $item->typename;
$item->voting =& $item->vote;
// custom field values
$item->fieldvalues = $custom;
}
return $items;
}