本文整理汇总了PHP中c2cTools::getArrayElement方法的典型用法代码示例。如果您正苦于以下问题:PHP c2cTools::getArrayElement方法的具体用法?PHP c2cTools::getArrayElement怎么用?PHP c2cTools::getArrayElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类c2cTools
的用法示例。
在下文中一共展示了c2cTools::getArrayElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildUserListCriteria
public static function buildUserListCriteria(&$criteria, &$params_list, $is_module = false, $mid = 'main_id')
{
if (empty($params_list)) {
return null;
}
$conditions = $values = $joins = array();
if ($is_module) {
$m = 'm';
$m2 = 'u';
$mid = 'm.id';
$midi18n = $mid;
$join = null;
$join_id = null;
$join_idi18n = null;
$join_i18n = 'user_i18n';
$join_private_data = 'user_pd';
} else {
$m = 'u';
$m2 = $m;
$mid = array('l' . $m, $mid);
$midi18n = implode('.', $mid);
$join = 'user';
$join_id = $join . '_id';
$join_idi18n = $join . '_idi18n';
$join_i18n = $join . '_i18n';
$join_private_data = $join . '_pd';
}
$nb_id = 0;
$nb_name = 0;
if ($is_module) {
$nb_id = self::buildConditionItem($conditions, $values, $joins, $params_list, 'List', $mid, array('id', 'users'), $join_id);
} else {
$nb_id = self::buildConditionItem($conditions, $values, $joins, $params_list, 'MultiId', $mid, 'users', $join_id);
}
$has_id = $nb_id == 1;
if (!$has_id) {
if ($is_module) {
self::buildConditionItem($conditions, $values, $joins, $params_list, 'Array', array($m, 'u', 'activities'), 'act', $join);
self::buildConditionItem($conditions, $values, $joins, $params_list, 'Georef', $join, 'geom', $join);
$nb_name = self::buildConditionItem($conditions, $values, $joins, $params_list, 'Mstring', array(array($midi18n, 'ui.search_name'), array($midi18n, 'upd.search_username')), 'utfnam', array(array($join_idi18n, $join_i18n), array($join_idi18n, $join_private_data)), array('User', 'UserPrivateData'));
if ($nb_name === 'no_result') {
return $nb_name;
} elseif ($nb_name[0]['nb_result'] == 0) {
$nb_id += $nb_name[1]['nb_result'];
} elseif ($nb_name[1]['nb_result'] == 0) {
$nb_id += $nb_name[0]['nb_result'];
}
}
// friends
$user_groups = c2cTools::getArrayElement($params_list, 'friends');
if (!is_null($user_groups)) {
$user_groups = explode(' ', $user_groups);
$user_ids = array();
$friend_ids = array();
$first_group = true;
foreach ($user_groups as $user_group) {
$user_group_ids = explode('-', $user_group);
$user_ids = array_merge($user_ids, $user_group_ids);
$conditions_temp = array("a.type = 'uo'");
$values_temp = array();
self::buildListCondition($conditions_temp, $values_temp, 'lu.main_id', $user_group);
$where = implode(' AND ', $conditions_temp);
$friends = Doctrine_Query::create()->select('DISTINCT a.main_id')->from('Association a')->leftJoin('a.MainMainAssociation lu')->where($where, $values_temp)->execute(array(), Doctrine::FETCH_ARRAY);
if (count($friends)) {
$friend_group_ids = array();
foreach ($friends as $friend) {
$friend_group_ids[] = $friend['main_id'];
}
$friend_group_ids = array_unique($friend_group_ids);
if ($first_group) {
$friend_ids = $friend_group_ids;
} else {
$friend_ids = array_intersect($friend_ids, $friend_group_ids);
}
}
$first_group = false;
}
if (count($friend_ids)) {
$friend_ids = array_diff($friend_ids, $user_ids);
}
if (count($friend_ids)) {
$params_list['friends'] = implode('-', $friend_ids);
if ($is_module) {
self::buildConditionItem($conditions, $values, $joins, $params_list, 'List', $mid, 'friends', $join_id);
} else {
self::buildConditionItem($conditions, $values, $joins, $params_list, 'MultiId', $mid, 'friends', $join_id);
}
} else {
return 'no_result';
}
}
self::buildConditionItem($conditions, $values, $joins, $params_list, 'Around', $m2 . '.geom', 'uarnd', $join);
$nb_name = self::buildConditionItem($conditions, $values, $joins, $params_list, 'String', array($midi18n, 'ui.search_name'), $is_module ? array('unam', 'name') : 'unam', array($join_idi18n, $join_i18n), 'User');
if ($nb_name === 'no_result') {
return $nb_name;
}
$nb_id += $nb_name;
self::buildConditionItem($conditions, $values, $joins, $params_list, 'String', array($midi18n, 'upd.search_username'), 'ufnam', array($join_idi18n, $join_private_data), 'UserPrivateData');
if ($nb_name === 'no_result') {
return $nb_name;
//.........这里部分代码省略.........
示例2: buildAreaCriteria
public static function buildAreaCriteria(&$criteria, &$params_list, $m = 'm', $m2 = null, $join = null, $use_around = true)
{
$conditions = $values = $joins = $joins_order = array();
// orderby criteria
$orderby_list = c2cTools::getRequestParameterArray(array('orderby', 'orderby2', 'orderby3'));
self::buildOrderCondition($joins_order, $orderby_list, array('range'), 'range');
self::buildOrderCondition($joins_order, $orderby_list, array('admin'), 'admin');
self::buildOrderCondition($joins_order, $orderby_list, array('country'), 'country');
self::buildOrderCondition($joins_order, $orderby_list, array('valley'), 'valley');
$criteria[3] += $joins_order;
if (empty($params_list)) {
return null;
}
if (c2cTools::getArrayElement($params_list, 'areas')) {
self::buildConditionItem($conditions, $values, $joins, $params_list, 'MultiId', array('g', 'linked_id'), 'areas', 'area_id');
}
if (c2cTools::getArrayElement($params_list, 'bbox')) {
self::buildConditionItem($conditions, $values, $joins, $params_list, 'Bbox', 'm.geom', 'bbox', null);
} elseif ($use_around && c2cTools::getArrayElement($params_list, 'around')) {
if (empty($m2)) {
$m2 = $m;
}
self::buildConditionItem($conditions, $values, $joins, $params_list, 'Around', $m2 . '.geom', 'around', $join);
}
if (!empty($conditions)) {
$criteria[0] = array_merge($criteria[0], $conditions);
$criteria[1] = array_merge($criteria[1], $values);
}
$criteria[2] += $joins;
$criteria[3] += $joins_order;
}