本文整理匯總了PHP中CB\Config::getDefaultGridViewColumns方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::getDefaultGridViewColumns方法的具體用法?PHP Config::getDefaultGridViewColumns怎麽用?PHP Config::getDefaultGridViewColumns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CB\Config
的用法示例。
在下文中一共展示了Config::getDefaultGridViewColumns方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getSolrFields
/**
* get solr columns for a node based on display columns
* @return array
*/
public function getSolrFields($nodeId = false, $templateId = false)
{
$nodeId = $nodeId;
// dummy codacy assignment
$rez = array('fields' => array(), 'sort' => array());
$ip =& $this->inputParams;
$defaultColumns = array_keys(Config::getDefaultGridViewColumns());
$displayColumns = $this->getDC();
$DC = empty($displayColumns['data']) ? array() : $displayColumns['data'];
if (!empty($DC)) {
foreach ($DC as $columnName => $column) {
if (is_array($column) && !empty($column['solr_column_name'])) {
$rez['fields'][$column['solr_column_name']] = 1;
if (empty($column['localSort'])) {
if (@$ip['sort'][0]['property'] == $columnName && !empty($ip['sort'][0]['direction'])) {
$rez['sort'][] = $column['solr_column_name'] . ' ' . strtolower($ip['sort'][0]['direction']);
} elseif (!empty($column['sort'])) {
$rez['sort'][] = $column['solr_column_name'] . ' ' . $column['sort'];
}
}
} elseif (is_scalar($column)) {
$a = explode(':', $column);
if ($a[0] == 'solr') {
$rez['fields'][$a[1]] = 1;
}
}
}
}
/* user clicked a column to sort by */
$property = null;
$dir = 'asc';
if (!empty($ip['userSort'])) {
$dir = strtolower($ip['sort'][0]['direction']);
if (in_array($dir, array('asc', 'desc')) && preg_match('/^[a-z_0-9]+$/i', $ip['sort'][0]['property'])) {
$prop = $ip['sort'][0]['property'];
if (!empty($DC[$prop]['solr_column_name'])) {
$col = $DC[$prop];
//also check if not marked as localSort
if (empty($col['localSort'])) {
$property = $col['solr_column_name'];
}
} elseif (in_array($prop, $defaultColumns)) {
$property = $prop;
}
}
} else {
/* get user state and check if user has a custom sorting */
$stateFrom = empty($displayColumns['from']) ? 'default' : $displayColumns['from'];
$state = $this->getState($stateFrom);
if (!empty($state['sort']['property'])) {
$property = $state['sort']['property'];
$dir = strtolower(Util\coalesce(@$state['sort']['direction'], 'asc'));
if (!empty($DC[$property]['solr_column_name']) && empty($DC[$property]['localSort'])) {
$property = $DC[$property]['solr_column_name'];
} elseif (!in_array($property, $defaultColumns)) {
$property = null;
}
}
}
if (!empty($property)) {
$rez['sort'] = 'ntsc asc,' . $property . ' ' . $dir;
}
/* end of get user state and check if user has a custom sorting */
if (!empty($rez['fields'])) {
$rez['fields'] = array_keys($rez['fields']);
}
return $rez;
}