public static function FetchFields($p_name = null, $p_articleType = null, $p_dataType = null, $p_negateName = false, $p_negateArticleType = false, $p_negateDataType = false, $p_selectHidden = true, $p_skipCache = false)
{
global $g_ado_db;
$cacheService = \Zend_Registry::get('container')->getService('newscoop.cache');
if (!$p_skipCache) {
$paramsArray['name'] = is_null($p_name) ? 'null' : $p_name;
$paramsArray['article_type'] = is_null($p_articleType) ? 'null' : $p_articleType;
$paramsArray['data_type'] = is_null($p_dataType) ? 'null' : $p_dataType;
$paramsArray['negate_name'] = $p_negateName == false ? 'false' : 'true';
$paramsArray['negate_article_type'] = $p_negateArticleType == false ? 'false' : 'true';
$paramsArray['negate_data_type'] = $p_negateDataType == false ? 'false' : 'true';
$paramsArray['select_hidden'] = $p_selectHidden == false ? 'false' : 'true';
$paramsArray['method'] = __METHOD__;
$cacheKey = $cacheService->getCacheKey($paramsArray, 'article_type');
if ($cacheService->contains($cacheKey)) {
$articleTypeFieldsList = $cacheService->fetch($cacheKey);
if ($articleTypeFieldsList !== false && is_array($articleTypeFieldsList)) {
return $articleTypeFieldsList;
}
}
}
$whereClauses = array();
if (isset($p_name)) {
$operator = $p_negateName ? '<>' : '=';
$whereClauses[] = "field_name {$operator} " . $g_ado_db->escape($p_name);
}
if (isset($p_articleType)) {
$operator = $p_negateArticleType ? '<>' : '=';
$whereClauses[] = "type_name {$operator} " . $g_ado_db->escape($p_articleType);
}
if (isset($p_dataType)) {
$operator = $p_negateDataType ? '<>' : '=';
$whereClauses[] = "field_type {$operator} " . $g_ado_db->escape($p_dataType);
}
if (!$p_selectHidden) {
$whereClauses[] = 'is_hidden = false';
}
$where = count($whereClauses) > 0 ? ' WHERE ' . implode(' and ', $whereClauses) : null;
$query = "SELECT * FROM `ArticleTypeMetadata` {$where} ORDER BY type_name ASC, field_weight ASC";
$rows = $g_ado_db->GetAll($query);
$fields = array();
foreach ($rows as $row) {
$field = new ArticleTypeField($row['type_name'], $row['field_name']);
if ($field->getPrintName() == '') {
$field->delete();
continue;
}
$fields[] = $field;
}
if (!$p_skipCache) {
$cacheService->save($cacheKey, $fields);
}
return $fields;
}