function & get_dataset(& $counter, $params = array()) { $mime_type = new mime_type(); $pricelists_array =& $this->_fetch($counter, $params); $file_ids = array(); foreach($pricelists_array as $id => $data) if($data['file_id'] > 0) $file_ids[$data['file_id']] = $data['file_id']; if(!$file_ids) return new array_dataset($pricelists_array); $files_counter = null; $file_data = fetch_by_node_ids($file_ids, 'file_object', $files_counter); foreach($pricelists_array as $id => $data) if($data['file_id'] > 0) { $pricelists_array[$id]['file_size'] = $file_data[$data['file_id']]['size']; $pricelists_array[$id]['file_icon'] = $mime_type->get_type_icon($file_data[$data['file_id']]['mime_type']); } return new array_dataset($pricelists_array); }
function get_message_file_data($message) { $file_data = ''; if ($message['file_id']) { $icon = mime_type::get_type_icon($message['mime_type']); $file_data = ", ['{$message['file_id']}', '{$icon}', '{$message['file_size']}', '{$message['image_width']}', '{$message['image_height']}']"; } return $file_data; }
list($message_type, $string) = explode(':', $message['message'], 2); if ($message_type == 'system_message') { echo "top.add_system_message('{$message_date}', {$message['id']}, '{$string}');\n"; echo "top.chat_user_event();"; } elseif ($message_type == 'warning_message') { $string = '<img src="/shared/images/error.gif" align="center">' . $string; echo "top.add_warning_message('{$message_date}', {$message['id']}, '{$string}');\n"; } break; case $message['recipient_id'] == $chat_user_data['id']: echo "top.add_private_incoming_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\");\n"; break; case $message['sender_id'] == $chat_user_data['id'] && $message['recipient_id'] > 0: echo "top.add_private_outgoing_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\");\n"; break; default: $file_data = ""; if ($message['file_id']) { $icon = mime_type::get_type_icon($message['mime_type']); $file_data = ", ['{$message['file_id']}', '{$icon}', '{$message['file_size']}', '{$message['image_width']}', '{$message['image_height']}']"; } echo "top.add_common_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\" {$file_data});\n"; } $last_message_id = $message['id']; } if (sizeof($messages)) { $last_message_ids[$chat_user_data['chat_room_id']] = $last_message_id; session::set("last_message_ids", $last_message_ids); echo "top.fetch_finished('{$last_message_id}');"; } echo "</script>";
echo "top.add_warning_message('{$message_date}', {$message['id']}, '{$string}');\n"; } break; case ($message['recipient_id'] == $chat_user_data['id']): echo "top.add_private_incoming_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\");\n"; break; case ($message['sender_id'] == $chat_user_data['id']) && ($message['recipient_id'] > 0): echo "top.add_private_outgoing_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\");\n"; break; default: $file_data = ""; if ($message['file_id']) { $icon = $mime_type->get_type_icon($message['mime_type']); $file_data = ", ['{$message['file_id']}', '{$icon}', '{$message['file_size']}', '{$message['image_width']}', '{$message['image_height']}']"; } echo "top.add_common_message('{$message_date}', {$message['id']}, '{$sender_name}', \"{$message_text}\" {$file_data});\n"; } $last_message_id = $message['id']; } if(sizeof($messages)) { $last_message_ids[$chat_user_data['chat_room_id']] = $last_message_id; session :: set("last_message_ids", $last_message_ids); echo "top.fetch_finished('{$last_message_id}');";