本文整理汇总了PHP中FieldList::getFieldsFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::getFieldsFromArray方法的具体用法?PHP FieldList::getFieldsFromArray怎么用?PHP FieldList::getFieldsFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FieldList
的用法示例。
在下文中一共展示了FieldList::getFieldsFromArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMappedFields
function getMappedFields($field_list, $id)
{
$res = array();
$debug = FALSE;
require_once $GLOBALS["where_framework"] . "/lib/lib.field.php";
$fl = new FieldList();
$field_map_info = $this->getFieldMap();
$field_map = $field_map_info["map"];
$map_custom_fields = $field_map_info["custom_fields"];
if ($debug) {
echo "<pre>\n";
print_r($field_map_info);
}
//--DEBUG--//
unset($field_map_info);
$fl->setFieldEntryTable($this->_getMapFromTable());
$user_field_arr = $fl->showFieldForUserArr(array($id), $field_list);
// to cache: arr[id]=res
if ($debug) {
print_r($user_field_arr);
}
//--DEBUG--//
if (is_array($user_field_arr[$id])) {
$field_val = $user_field_arr[$id];
} else {
$field_val = array();
}
// This way we are going to load only the information
// about the fields we really need.
$field_list = $field_list + $map_custom_fields;
if ($debug) {
print_r($field_list);
}
//--DEBUG--//
$field_info = $fl->getFieldsFromArray($field_list);
// to cache? maybe one for all
if ($debug) {
print_r($field_info);
}
//--DEBUG--//
// $mro: Map Resource Object (array)
// We'll use this later to read predefined fields names
$mro = array();
foreach ($this->getResourceList("list") as $code => $resource) {
require_once $resource["class_path"] . $resource["class_file"];
$mro[$code] = new $resource["class_name"]();
}
// Creating empty schema that will contain useful information
// like field description..
foreach ($mro as $resource => $resource_obj) {
foreach ($resource_obj->getRawPredefinedFields() as $code) {
$res[$resource]["predefined"][$code]["description"] = $resource_obj->getPredefinedFieldLabel($code);
$res[$resource]["predefined"][$code]["value"] = "";
}
}
foreach ($field_info as $field_id => $info) {
if (isset($field_map[$field_id])) {
$type = $field_map[$field_id]["type"];
$resource = $field_map[$field_id]["resource"];
$new_id = $field_map[$field_id]["map_to"];
if ($type == "custom") {
$res[$resource][$type][$new_id]["description"] = $field_info[$new_id][FIELD_INFO_TRANSLATION];
}
$res[$resource][$type][$new_id]["value"] = $field_val[$field_id];
} else {
if (!isset($field_map[$field_id]) && !in_array($field_id, $map_custom_fields)) {
$resource = "_not_mapped";
$type = "custom";
$res[$resource][$type][$field_id]["description"] = $field_info[$field_id][FIELD_INFO_TRANSLATION];
$res[$resource][$type][$field_id]["value"] = $field_val[$field_id];
if ($debug && empty($field_val[$field_id])) {
echo $field_id . " :: ";
}
}
}
}
if ($debug) {
print_r($res);
echo "\n</pre>\n";
}
//--DEBUG--//
return $res;
}
示例2: multimod_actionTask
public function multimod_actionTask()
{
if (!$this->permissions['mod_user']) {
$output = array('success' => false, 'message' => $this->_getErrorMessage('no permission'));
echo $this->json->encode($output);
return;
}
$output = false;
$users_str = Get::req('users', DOTY_STRING, "");
if (!$users_str) {
$output = array('success' => false, 'message' => $this->_getErrorMessage('invalid input'));
echo $this->json->encode($output);
return;
}
$users = explode(",", $users_str);
if (empty($users)) {
$output = array('success' => false, 'message' => $this->_getErrorMessage('invalid input'));
echo $this->json->encode($output);
return;
}
$info = new stdClass();
$to_update = Get::req('to_change', DOTY_MIXED, array());
$count_updated = 0;
if (!empty($to_update)) {
foreach ($to_update as $property) {
}
}
//read input data
$sel_properties = Get::req('multimod_sel', DOTY_MIXED, array());
$pref_properties = Get::req('multimod_selpref', DOTY_MIXED, array());
$field_properties = Get::req('multimod_selfield', DOTY_MIXED, array());
//validate input data
$info = new stdClass();
if (isset($sel_properties['firstname'])) {
$info->firstname = Get::req('firstname', DOTY_STRING, "");
}
if (isset($sel_properties['lastname'])) {
$info->lastname = Get::req('lastname', DOTY_STRING, "");
}
if (isset($sel_properties['email'])) {
$info->email = Get::req('email', DOTY_STRING, "");
}
if (isset($sel_properties['password'])) {
$pwd_1 = Get::req('new_password', DOTY_STRING, "");
$pwd_2 = Get::req('new_password_confirm', DOTY_STRING, "");
if ($pwd_1 == $pwd_2) {
$info->password = $pwd_1;
} else {
$output = array('success' => false, 'message' => $this->_getErrorMessage('password mismatch'));
echo $this->json->encode($output);
return;
}
}
if (isset($sel_properties['force_change'])) {
$info->force_change = Get::req('force_change', DOTY_INT, 0) > 0;
}
if (isset($sel_properties['level'])) {
$info->level = Get::req('level', DOTY_STRING, "");
}
/*
if (isset($sel_properties['facebook_id'])) $info->facebook_id = Get::req('facebook_id', DOTY_STRING, "");
if (isset($sel_properties['twitter_id'])) $info->twitter_id = Get::req('twitter_id', DOTY_STRING, "");
if (isset($sel_properties['linkedin_id'])) $info->linkedin_id = Get::req('linkedin_id', DOTY_STRING, "");
if (isset($sel_properties['google_id'])) $info->google_id = Get::req('google_id', DOTY_STRING, "");
*/
if (!empty($field_properties)) {
require_once _adm_ . '/lib/lib.field.php';
$fields = new FieldList();
$selected_fields = array_keys($field_properties);
$finfo = $fields->getFieldsFromArray($selected_fields);
$field_info = array();
foreach ($finfo as $id_field => $data) {
$input_data = Get::req('field_' . $data[FIELD_INFO_TYPE], DOTY_MIXED, array());
if (isset($input_data[$id_field])) {
$value_to_set = "";
switch ($data[FIELD_INFO_TYPE]) {
case "":
$value_to_set = Format::dateDb($input_data[$id_field], 'date');
break;
default:
$value_to_set = $input_data[$id_field];
}
$field_info[$id_field] = $value_to_set;
}
}
$info->__fields = $field_info;
}
if (!empty($pref_properties)) {
$info->__preferences = $pref_properties;
}
$res = $this->model->updateMultipleUsers($users, $info);
if (!$res) {
$output = array('success' => false, 'message' => $this->_getErrorMessage('server error'));
} else {
$output = array('success' => true, 'update' => $count_updated);
}
echo $this->json->encode($output);
}