本文整理汇总了PHP中ExtraFieldValue::get_values_by_handler_and_field_id方法的典型用法代码示例。如果您正苦于以下问题:PHP ExtraFieldValue::get_values_by_handler_and_field_id方法的具体用法?PHP ExtraFieldValue::get_values_by_handler_and_field_id怎么用?PHP ExtraFieldValue::get_values_by_handler_and_field_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExtraFieldValue
的用法示例。
在下文中一共展示了ExtraFieldValue::get_values_by_handler_and_field_id方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_handler_extra_data
/**
*
* @param int $item_id (session_id, question_id, course id)
* @return array
*/
public function get_handler_extra_data($item_id)
{
if (empty($item_id)) {
return array();
}
$extra_data = array();
$fields = self::get_all();
$field_values = new ExtraFieldValue($this->type);
if (!empty($fields) > 0) {
foreach ($fields as $field) {
$field_value = $field_values->get_values_by_handler_and_field_id($item_id, $field['id']);
if ($field_value) {
$field_value = $field_value['field_value'];
switch ($field['field_type']) {
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
$selected_options = explode('::', $field_value);
$extra_data['extra_' . $field['field_variable']]['extra_' . $field['field_variable']] = $selected_options[0];
$extra_data['extra_' . $field['field_variable']]['extra_' . $field['field_variable'] . '_second'] = $selected_options[1];
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$field_value = explode(';', $field_value);
case ExtraField::FIELD_TYPE_RADIO:
$extra_data['extra_' . $field['field_variable']]['extra_' . $field['field_variable']] = $field_value;
break;
default:
$extra_data['extra_' . $field['field_variable']] = $field_value;
break;
}
} else {
// Set default values
if (isset($field['field_default_value']) && !empty($field['field_default_value'])) {
$extra_data['extra_' . $field['field_variable']] = $field['field_default_value'];
}
}
}
}
return $extra_data;
}
示例2: get_user_data
/**
* Get the users to display on the current page.
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $is_western_name_order;
global $extraFields;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$course_info = api_get_course_info();
$sessionId = api_get_session_id();
$course_code = $course_info['code'];
$a_users = array();
// limit
if (!isset($_GET['keyword']) || empty($_GET['keyword'])) {
$limit = 'LIMIT ' . intval($from) . ',' . intval($number_of_items);
}
if (!in_array($direction, array('ASC', 'DESC'))) {
$direction = 'ASC';
}
switch ($column) {
case 2:
//official code
$order_by = 'ORDER BY user.official_code ' . $direction;
break;
case 3:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
} else {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
}
break;
case 4:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
case 5:
//username
$order_by = 'ORDER BY user.username ' . $direction;
break;
default:
if ($is_western_name_order) {
$order_by = 'ORDER BY user.lastname ' . $direction . ', user.firstname ' . $direction;
} else {
$order_by = 'ORDER BY user.firstname ' . $direction . ', user.lastname ' . $direction;
}
break;
}
$active = isset($_GET['active']) ? $_GET['active'] : null;
if (empty($sessionId)) {
$status = $type;
} else {
if ($type == COURSEMANAGER) {
$status = 2;
} else {
$status = 0;
}
}
$a_course_users = CourseManager::get_user_list_from_course_code($course_code, $sessionId, $limit, $order_by, $status, null, false, false, null, array(), array(), $active);
foreach ($a_course_users as $user_id => $o_course_user) {
if (isset($_GET['keyword']) && searchUserKeyword($o_course_user['firstname'], $o_course_user['lastname'], $o_course_user['username'], $o_course_user['official_code'], $_GET['keyword']) || !isset($_GET['keyword']) || empty($_GET['keyword'])) {
$groupsNameList = GroupManager::getAllGroupPerUserSubscription($user_id);
$groupsNameListParsed = [];
if (!empty($groupsNameList)) {
$groupsNameListParsed = array_column($groupsNameList, 'name');
}
$temp = array();
if (api_is_allowed_to_edit(null, true)) {
$userInfo = api_get_user_info($user_id);
$photo = '<img src="' . $userInfo['avatar_small'] . '" alt="' . $userInfo['complete_name'] . '" title="' . $userInfo['complete_name'] . '" />';
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
// Groups.
$temp[] = implode(', ', $groupsNameListParsed);
// Status
$default_status = get_lang('Student');
if (isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1 || isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2) {
$default_status = get_lang('CourseManager');
} elseif (isset($o_course_user['is_tutor']) && $o_course_user['is_tutor'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
// Active
$temp[] = $o_course_user['active'];
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$extraFieldValue = new ExtraFieldValue('user');
$data = $extraFieldValue->get_values_by_handler_and_field_id($user_id, $extraField['id']);
$temp[] = $data['value'];
//.........这里部分代码省略.........
示例3: getDataAndFormattedValues
/**
* Get the extra fields and their formatted values
* @param int|string $itemId The item ID (It could be a session_id, course_id or user_id)
* @return array The extra fields data
*/
public function getDataAndFormattedValues($itemId)
{
$valuesData = array();
$fields = $this->get_all();
foreach ($fields as $field) {
if ($field['visible'] != '1') {
continue;
}
$fieldValue = new ExtraFieldValue($this->type);
$valueData = $fieldValue->get_values_by_handler_and_field_id($itemId, $field['id'], true);
if (!$valueData) {
continue;
}
$displayedValue = get_lang('None');
switch ($field['field_type']) {
case ExtraField::FIELD_TYPE_CHECKBOX:
if ($valueData !== false && $valueData['value'] == '1') {
$displayedValue = get_lang('Yes');
} else {
$displayedValue = get_lang('No');
}
break;
case ExtraField::FIELD_TYPE_DATE:
if ($valueData !== false && !empty($valueData['value'])) {
$displayedValue = api_format_date($valueData['value'], DATE_FORMAT_LONG_NO_DAY);
}
break;
case ExtraField::FIELD_TYPE_FILE_IMAGE:
if ($valueData === false || empty($valueData['value'])) {
break;
}
if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) {
break;
}
$image = Display::img(api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], $field['display_text'], array('width' => '300'));
$displayedValue = Display::url($image, api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], array('target' => '_blank'));
break;
case ExtraField::FIELD_TYPE_FILE:
if ($valueData === false || empty($valueData['value'])) {
break;
}
if (!file_exists(api_get_path(SYS_UPLOAD_PATH) . $valueData['value'])) {
break;
}
$displayedValue = Display::url(get_lang('Download'), api_get_path(WEB_UPLOAD_PATH) . $valueData['value'], array('title' => $field['display_text'], 'target' => '_blank'));
break;
default:
$displayedValue = $valueData['value'];
break;
}
$valuesData[] = array('text' => $field['display_text'], 'value' => $displayedValue);
}
return $valuesData;
}
示例4: getQuestionListPagination
/**
*
* @param int $start
* @param int $limit
* @param int $sidx
* @param string $sord
* @param array $where_condition
* @param array $extraFields
*/
public function getQuestionListPagination($start, $limit, $sidx, $sord, $where_condition = array(), $extraFields = array())
{
if (!empty($this->id)) {
$category_list = TestCategory::getListOfCategoriesNameForTest($this->id, false);
$TBL_EXERCICE_QUESTION = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
$TBL_QUESTIONS = Database::get_course_table(TABLE_QUIZ_QUESTION);
$sql = "SELECT q.iid\n FROM {$TBL_EXERCICE_QUESTION} e INNER JOIN {$TBL_QUESTIONS} q\n ON (e.question_id = q.iid AND e.c_id = " . $this->course_id . " )\n\t\t\t\t\tWHERE e.exercice_id\t= '" . Database::escape_string($this->id) . "'\n\t\t\t\t\t";
$orderCondition = "ORDER BY question_order";
if (!empty($sidx) && !empty($sord)) {
if ($sidx == 'question') {
if (in_array(strtolower($sord), array('desc', 'asc'))) {
$orderCondition = " ORDER BY q.{$sidx} {$sord}";
}
}
}
$sql .= $orderCondition;
$limitCondition = null;
if (isset($start) && isset($limit)) {
$start = intval($start);
$limit = intval($limit);
$limitCondition = " LIMIT {$start}, {$limit}";
}
$sql .= $limitCondition;
$result = Database::query($sql);
$questions = array();
if (Database::num_rows($result)) {
if (!empty($extraFields)) {
$extraFieldValue = new ExtraFieldValue('question');
}
while ($question = Database::fetch_array($result, 'ASSOC')) {
/** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($question['iid']);
$category_labels = TestCategory::return_category_labels($objQuestionTmp->category_list, $category_list);
if (empty($category_labels)) {
$category_labels = "-";
}
// Question type
list($typeImg, $typeExpl) = $objQuestionTmp->get_type_icon_html();
$question_media = null;
if (!empty($objQuestionTmp->parent_id)) {
$objQuestionMedia = Question::read($objQuestionTmp->parent_id);
$question_media = Question::getMediaLabel($objQuestionMedia->question);
}
$questionType = Display::tag('div', Display::return_icon($typeImg, $typeExpl, array(), ICON_SIZE_MEDIUM) . $question_media);
$question = array('id' => $question['iid'], 'question' => $objQuestionTmp->selectTitle(), 'type' => $questionType, 'category' => Display::tag('div', '<a href="#" style="padding:0px; margin:0px;">' . $category_labels . '</a>'), 'score' => $objQuestionTmp->selectWeighting(), 'level' => $objQuestionTmp->level);
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$value = $extraFieldValue->get_values_by_handler_and_field_id($question['id'], $extraField['id']);
$stringValue = null;
if ($value) {
$stringValue = $value['field_value'];
}
$question[$extraField['field_variable']] = $stringValue;
}
}
$questions[] = $question;
}
}
return $questions;
}
}
示例5: ExtraFieldValue
static function get_horario_value($session_id)
{
$extra_field_value = new ExtraFieldValue('session');
//Getting horario info
$extra_field = new ExtraField('session');
$extra_field_info = $extra_field->get_handler_field_info_by_field_variable('horario');
$horario_info = $extra_field_value->get_values_by_handler_and_field_id($session_id, $extra_field_info['id']);
$extra_field_option = new ExtraFieldOption('session');
$horario_info = $extra_field_option->get_field_option_by_field_and_option($extra_field_info['id'], $horario_info['field_value']);
$time = "08:00";
if (isset($horario_info) && isset($horario_info[0])) {
$horario = $horario_info[0]['option_display_text'];
$horario_array = explode(' ', $horario);
//Schedule format is "(01) 07:00 09:00" in this case. Adapt to your case
if (isset($horario_array[1])) {
$time = $horario_array[1];
}
}
return $time;
}
示例6: get_user_data
//.........这里部分代码省略.........
if (api_is_allowed_to_edit(null, true)) {
$temp[] = $user_id;
$image_path = UserManager::get_user_picture_path_by_id(
$user_id,
'web',
false,
true
);
$user_profile = UserManager::get_picture_user(
$user_id,
$image_path['file'],
22,
USER_IMAGE_SIZE_SMALL,
' width="22" height="22" '
);
if (!api_is_anonymous()) {
$photo = '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
} else {
$photo = '<img src="'.$user_profile['file'].'" '.$user_profile['style'].' alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
}
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
// Description.
$temp[] = isset($o_course_user['role']) ? $o_course_user['role'] : null;
// Groups.
$temp[] = implode(', ', $groupsNameList);
// Status
$default_status = '-';
if ((isset($o_course_user['status_rel']) && $o_course_user['status_rel'] == 1) ||
(isset($o_course_user['status_session']) && $o_course_user['status_session'] == 2)
) {
$default_status = get_lang('CourseManager');
} elseif (isset($o_course_user['tutor_id']) && $o_course_user['tutor_id'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
// Active
$temp[] = $o_course_user['active'];
if (!empty($extraFields)) {
foreach ($extraFields as $extraField) {
$extraFieldValue = new ExtraFieldValue('user');
$data = $extraFieldValue->get_values_by_handler_and_field_id(
$user_id,
$extraField['id']
);
$temp[] = $data['field_value'];
}
}
// User id for actions
$temp[] = $user_id;
} else {
$image_path = UserManager::get_user_picture_path_by_id($user_id, 'web', false, true);
$image_repository = $image_path['dir'];
$existing_image = $image_path['file'];
if (!api_is_anonymous()) {
$photo= '<a href="userInfo.php?'.api_get_cidreq().'&origin='.$origin.'&uInfo='.$user_id.'" title="'.get_lang('Info').'" ><img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" /></a>';
} else {
$photo= '<img src="'.$image_repository.$existing_image.'" alt="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" width="22" height="22" title="'.api_get_person_name($o_course_user['firstname'], $o_course_user['lastname']).'" />';
}
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
}
$temp[] = $o_course_user['username'];
$temp[] = $o_course_user['role'];
// Group.
$temp[] = implode(', ', $groupsNameList);
if ($course_info['unsubscribe'] == 1) {
//User id for actions
$temp[] = $user_id;
}
}
$a_users[$user_id] = $temp;
}
}
return $a_users;
}
示例7: SortableTableFromArray
}
echo Display::page_subheader(get_lang('Sessions'));
$table = new SortableTableFromArray($session_list, 0, 20, 'user_table');
$table->display();
}
$extra_field = new ExtraField('course');
$extra_fields = $extra_field->get_all();
if (!empty($extra_fields)) {
echo Display::page_subheader(get_lang('ExtraFields'));
echo '<table class="data_table">';
foreach ($extra_fields as $field) {
if ($field['field_visible'] != '1') {
continue;
}
$obj = new ExtraFieldValue($extra_field->type);
$result = $obj->get_values_by_handler_and_field_id($course_info['code'], $field['id'], true);
$value = null;
if ($result) {
$value = $result['field_value'];
if (is_bool($value)) {
$value = $value ? get_lang('Yes') : get_lang('No');
}
} else {
$value = '-';
}
echo "<tr>";
echo "<td> {$field['field_display_text']} </td>";
echo "<td> {$value} </td>";
echo "</tr>";
}
echo "</table>";