本文整理汇总了PHP中FlexicontentFields::getFiltered方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::getFiltered方法的具体用法?PHP FlexicontentFields::getFiltered怎么用?PHP FlexicontentFields::getFiltered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::getFiltered方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
}
示例2: _getFiltered
/**
* Method to get the active filter result
*
* @access private
* @return string
* @since 1.5
*/
function _getFiltered(&$filter, $value, $return_sql = true)
{
$field_type = $filter->field_type;
// Sanitize filter values as integers for field that use integer values
if (in_array($field_type, array('createdby', 'modifiedby', 'type', 'categories', 'tags'))) {
$values = is_array($value) ? $value : array($value);
foreach ($values as $i => $v) {
$values[$i] = (int) $v;
}
}
switch ($field_type) {
case 'createdby':
$filter_query = ' AND i.created_by IN (' . implode(",", $values) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'modifiedby':
$filter_query = ' AND i.modified_by IN (' . implode(",", $values) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'type':
//$filter_query = ' AND ie.type_id IN ('. implode(",", $values) .')'; // no db quoting needed since these were typecasted to ints
$query = 'SELECT item_id' . ' FROM #__flexicontent_items_ext' . ' WHERE type_id IN (' . implode(",", $values) . ')';
//$filter_query = ' AND i.id IN (' . $query . ')';
break;
case 'state':
$stateids = array('PE' => -3, 'OQ' => -4, 'IP' => -5, 'P' => 1, 'U' => 0, 'A' => FLEXI_J16GE ? 2 : -1, 'T' => -2);
$values = is_array($value) ? $value : array($value);
$filt_states = array();
foreach ($values as $i => $v) {
if (isset($stateids[$v])) {
$filt_states[] = $stateids[$v];
}
}
$filter_query = !count($values) ? ' AND 0 ' : ' AND i.state IN (' . implode(",", $filt_states) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'categories':
//$filter_query = ' AND rel.catid IN ('. implode(",", $values) .')';
global $globalcats;
$cparams = $this->_params;
$display_subcats = $cparams->get('display_subcategories_items', 2);
// include subcategory items
$query_catids = array();
foreach ($values as $id) {
$query_catids[$id] = 1;
if ($display_subcats == 2 && !empty($globalcats[$id]->descendantsarray)) {
foreach ($globalcats[$id]->descendantsarray as $subcatid) {
$query_catids[$subcatid] = 1;
}
}
}
$query_catids = array_keys($query_catids);
$query = 'SELECT itemid' . ' FROM #__flexicontent_cats_item_relations' . ' WHERE catid IN (' . implode(",", $query_catids) . ')';
//$filter_query = ' AND i.id IN (' . $query . ')';
break;
case 'tags':
$query = 'SELECT itemid' . ' FROM #__flexicontent_tags_item_relations' . ' WHERE tid IN (' . implode(",", $values) . ')';
//$filter_query = ' AND i.id IN (' . $query . ')';
break;
default:
// Make sure plugin file of current file is loaded and then check if custom filtering function exists
$field_type_file = $filter->iscore ? 'core' : $field_type;
$path = JPATH_ROOT . DS . 'plugins' . DS . 'flexicontent_fields' . DS . strtolower($field_type_file) . (FLEXI_J16GE ? DS . strtolower($field_type_file) : "") . '.php';
if (file_exists($path)) {
require_once $path;
$method_exists = method_exists("plgFlexicontent_fields{$field_type_file}", "getFiltered");
}
// Use custom field filtering if 'getFiltered' plugin method exists, otherwise try to use our default filtering function
$filtered = !@$method_exists ? FlexicontentFields::getFiltered($filter, $value, $return_sql) : FLEXIUtilities::call_FC_Field_Func($field_type_file, 'getFiltered', array(&$filter, &$value, &$return_sql));
break;
}
if (!isset($filter_query)) {
if (isset($filtered)) {
// nothing to do
} else {
if (!isset($query)) {
$filtered = '';
echo "Unhandled case for filter: " . $field->name . " in 'FlexicontentModelCategory::getFiltered()', query variable not set<br/>\n";
} else {
if (!$return_sql) {
//echo "<br>GET FILTERED Items (cat model) -- [".$filter->name."] using in-query ids :<br>". $query."<br>\n";
$db = JFactory::getDBO();
$db->setQuery($query);
$filtered = $db->loadColumn();
if ($db->getErrorNum()) {
JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error');
}
} else {
if ($return_sql === 2) {
$db = JFactory::getDBO();
static $iids_tblname = array();
if (!isset($iids_tblname[$filter->id])) {
$iids_tblname[$filter->id] = 'fc_filter_iids_' . $filter->id;
//.........这里部分代码省略.........
示例3: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
if (!$filter->iscore) {
return;
}
//echo __FUNCTION__ ." of CORE field type: ".$filter->field_type;
$isdate = in_array($filter->field_type, array('date', 'created', 'modified')) || $filter->parameters->get('isdate', 0);
if ($isdate) {
$date_filter_group = $filter->parameters->get('date_filter_group', 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
} else {
$date_valformat = '%Y-%m-%d';
}
}
$filter->filter_colname = sprintf(' DATE_FORMAT(c.%s, "%s") ', $filter->field_type, $date_valformat);
$filter->filter_valuesjoin = ' ';
// ... a space, (indicates not needed)
$filter->filter_valueformat = sprintf(' DATE_FORMAT(__filtervalue__, "%s") ', $date_valformat);
// 'isindexed' is not applicable for basic index and CORE fields
$filter->isindexed = 0;
//in_array($filter->field_type, array('type','state','tags','categories','created','createdby','modified','modifiedby'));
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
} else {
return $return_sql ? ' AND i.id IN (0) ' : array(0);
}
}
示例4: _getFiltered
/**
* Method to get the active filter result
*
* @access private
* @return string
* @since 1.5
*/
function _getFiltered(&$filter, $value)
{
$field_type = $filter->field_type;
// Sanitize filter values as integers for field that use integer values
if (in_array($field_type, array('createdby', 'modifiedby', 'type', 'categories', 'tags'))) {
$values = is_array($value) ? $value : array($value);
foreach ($values as $i => $v) {
$values[$i] = (int) $v;
}
}
switch ($field_type) {
case 'createdby':
$filter_query = ' AND i.created_by IN (' . implode(",", $values) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'modifiedby':
$filter_query = ' AND i.modified_by IN (' . implode(",", $values) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'type':
//$filter_query = ' AND ie.type_id IN ('. implode(",", $values) .')'; // no db quoting needed since these were typecasted to ints
$query = 'SELECT item_id' . ' FROM #__flexicontent_items_ext' . ' WHERE type_id IN (' . implode(",", $values) . ')';
$filter_query = ' AND i.id IN (' . $query . ')';
break;
case 'state':
$stateids = array('PE' => -3, 'OQ' => -4, 'IP' => -5, 'P' => 1, 'U' => 0, 'A' => FLEXI_J16GE ? 2 : -1, 'T' => -2);
$values = is_array($value) ? $value : array($value);
$filt_states = array();
foreach ($values as $i => $v) {
if (isset($stateids[$v])) {
$filt_states[] = $stateids[$v];
}
}
$filter_query = !count($values) ? ' AND 1=0 ' : ' AND i.state IN (' . implode(",", $filt_states) . ')';
// no db quoting needed since these were typecasted to ints
break;
case 'categories':
//$filter_query = ' AND rel.catid IN ('. implode(",", $values) .')';
$query = 'SELECT itemid' . ' FROM #__flexicontent_cats_item_relations' . ' WHERE catid IN (' . implode(",", $values) . ')';
$filter_query = ' AND i.id IN (' . $query . ')';
break;
case 'tags':
$query = 'SELECT itemid' . ' FROM #__flexicontent_tags_item_relations' . ' WHERE tid IN (' . implode(",", $values) . ')';
$filter_query = ' AND i.id IN (' . $query . ')';
break;
default:
// Make sure plugin file of current file is loaded and then check if custom filtering function exists
$field_type_file = $filter->iscore ? 'core' : $field_type;
$path = JPATH_ROOT . DS . 'plugins' . DS . 'flexicontent_fields' . DS . strtolower($field_type_file) . (FLEXI_J16GE ? DS . strtolower($field_type_file) : "") . '.php';
if (file_exists($path)) {
require_once $path;
$method_exists = method_exists("plgFlexicontent_fields{$field_type_file}", "getFiltered");
}
// Use custom field filtering if 'getFiltered' plugin method exists, otherwise try to use our default filtering function
$filtered = !@$method_exists ? FlexicontentFields::getFiltered($filter, $value, $return_sql = true) : FLEXIUtilities::call_FC_Field_Func($field_type_file, 'getFiltered', array(&$filter, &$value));
// An empty return value means no matching values we found
$filtered = empty($filtered) ? ' AND 1=0' : $filtered;
// A string mean a subquery was returned, while an array means that item ids we returned
$filter_query = is_array($filtered) ? ' AND i.id IN (' . implode(',', $filtered) . ')' : $filtered;
break;
}
//echo "<br/>".$filter_query."<br/>";
return $filter_query;
}
示例5: getFiltered
function getFiltered(&$filter, $value)
{
// execute the code only if the field type match the plugin type
if ( !in_array($filter->field_type, self::$field_types) ) return;
return FlexicontentFields::getFiltered($filter, $value, $return_sql=true);
}
示例6: getFiltered
function getFiltered(&$filter, $value)
{
if (!$filter->iscore) {
return;
}
//echo __FUNCTION__ ." of CORE field type: ".$filter->field_type;
$isdate = in_array($filter->field_type, array('date', 'created', 'modified')) || $filter->parameters->get('isdate', 0);
if ($isdate) {
$date_filter_group = $filter->parameters->get('date_filter_group', 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
} else {
$date_valformat = '%Y-%m-%d';
}
}
$filter->filter_colname = sprintf(' DATE_FORMAT(c.%s, "%s") ', $filter->field_type, $date_valformat);
$filter->filter_valuesjoin = ' ';
// ... a space, (indicates not needed)
$filter->filter_valueformat = sprintf(' DATE_FORMAT(__filtervalue__, "%s") ', $date_valformat);
// Dates are given in user calendar convert them to valid SQL dates
$sql = FlexicontentFields::getFiltered($filter, $value, $return_sql = true);
//echo "<br/>\n" .print_r($sql,true). "<br/>\n";
return $sql;
} else {
return array(0);
}
}
示例7: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
// execute the code only if the field type match the plugin type
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$filter->filter_colname = ' CAST(rel.value AS UNSIGNED)';
$filter->filter_valuesjoin = null;
// use default
$filter->filter_valueformat = null;
// use default
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
}
示例8: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$date_filter_group = $filter->parameters->get('date_filter_group', 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
} else {
$date_valformat = '%Y-%m-%d';
}
}
$date_source = $filter->parameters->get('date_source', 0);
if (!$date_source) {
$filter->filter_colname = sprintf(' DATE_FORMAT(rel.value, "%s") ', $date_valformat);
} else {
$_value_col = $date_source == 1 ? 'c.publish_up' : 'c.publish_down';
$filter->filter_colname = sprintf(' DATE_FORMAT(%s, "%s") ', $_value_col, $date_valformat);
}
$filter->filter_colname = sprintf(' DATE_FORMAT(rel.value, "%s") ', $date_valformat);
$filter->filter_valuesjoin = null;
// use default
$filter->filter_valueformat = sprintf(' DATE_FORMAT(__filtervalue__, "%s") ', $date_valformat);
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
}
示例9: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$date_filter_group = $filter->parameters->get('date_filter_group', 'month');
if ($date_filter_group == 'year') {
$date_valformat = '%Y';
} else {
if ($date_filter_group == 'month') {
$date_valformat = '%Y-%m';
} else {
$date_valformat = '%Y-%m-%d';
}
}
$date_source = $filter->parameters->get('date_source', 0);
if (!$date_source || $date_source == 3) {
$filter->filter_colname = sprintf(' DATE_FORMAT(rel.value, "%s") ', $date_valformat);
$filter->filter_valuesjoin = null;
// use default query
} else {
if ($date_source == 1 || $date_source == 2) {
$_value_col = $date_source == 1 ? 'c.publish_up' : 'c.publish_down';
$filter->filter_colname = sprintf(' DATE_FORMAT(%s, "%s") ', $_value_col, $date_valformat);
$filter->filter_valuesjoin = ' ';
// a space to prevent using default query and instead use content table
} else {
JFactory::getApplication()->enqueueMessage(__FUNCTION__ . " for field: '" . $filter->label . ", date_source: " . $date_source . " not implemented", 'notice');
}
}
$filter->filter_valueformat = sprintf(' DATE_FORMAT(__filtervalue__, "%s") ', $date_valformat);
// format of given values must be same as format of the value-column
return FlexicontentFields::getFiltered($filter, $value, $return_sql);
}
示例10: getFiltered
function getFiltered(&$filter, $value)
{
if ( !in_array($filter->field_type, self::$field_types) ) return;
$props_type = $filter->parameters->get('props_type');
switch ($props_type)
{
case 'language':
$filter->filter_colname = 'language';
$filter->filter_valuesjoin = ' '; // ... a space, (indicates not needed)
$filter->filter_valueformat = ' ';
// Dates are given in user calendar convert them to valid SQL dates
$sql = FlexicontentFields::getFiltered($filter, $value, $return_sql=true);
break;
default:
$sql = '';
break;
}
return $sql;
}
示例11: getFiltered
function getFiltered(&$filter, $value, $return_sql = true)
{
if (!in_array($filter->field_type, self::$field_types)) {
return;
}
$props_type = $filter->parameters->get('props_type');
switch ($props_type) {
case 'language':
$filter->filter_colname = 'language';
$filter->filter_valuesjoin = ' ';
// ... a space, (indicates not needed)
$filter->filter_valueformat = ' ';
// Dates are given in user calendar convert them to valid SQL dates
$query = FlexicontentFields::getFiltered($filter, $value, $return_sql);
break;
default:
return $return_sql ? ' AND i.id IN (0) ' : array(0);
break;
}
if (!$return_sql) {
//echo "<br>plgFlexicontent_fieldsCoreprops::getFiltered() -- [".$filter->name."] doing: <br>". $query."<br><br>\n";
$db = JFactory::getDBO();
$db->setQuery($query);
$filtered = $db->loadColumn();
if ($db->getErrorNum()) {
JFactory::getApplication()->enqueueMessage(__FUNCTION__ . '(): SQL QUERY ERROR:<br/>' . nl2br($db->getErrorMsg()), 'error');
}
return $filtered;
} else {
return ' AND i.id IN (' . $query . ')';
}
}