本文整理汇总了PHP中phpbb\request\request_interface::overwrite方法的典型用法代码示例。如果您正苦于以下问题:PHP request_interface::overwrite方法的具体用法?PHP request_interface::overwrite怎么用?PHP request_interface::overwrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpbb\request\request_interface
的用法示例。
在下文中一共展示了request_interface::overwrite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_upload
/**
* Handle upload.
*/
protected function handle_upload()
{
$upload = $this->request->file($this->form_name);
if ($upload['name'] != 'none' && trim($upload['name'])) {
// Try uploading the file.
$this->upload_file();
// Store for easier access
$this->errors = array_merge($this->errors, $this->filedata['error']);
// If we had no problems we can submit the data to the database.
if (empty($this->filedata['error'])) {
$order_id = $this->set_custom_order ? $this->operator->get_max_custom_index() + 1 : 0;
$data = array('attachment_id' => 0, 'physical_filename' => $this->filedata['physical_filename'], 'attachment_directory' => $this->filedata['attachment_directory'], 'real_filename' => $this->filedata['real_filename'], 'extension' => $this->filedata['extension'], 'mimetype' => $this->filedata['mimetype'], 'filesize' => $this->filedata['filesize'], 'filetime' => $this->filedata['filetime'], 'hash' => $this->filedata['md5_checksum'], 'attachment_order' => $order_id, 'attachment_comment' => $this->request->variable('filecomment', '', true), 'object_type' => $this->object_type, 'object_id' => $this->object_id);
$attachment = $this->operator->get_new_entity($data);
// Create thumbnail
$has_thumbnail = $is_preview = false;
if ($this->filedata['is_image']) {
$has_thumbnail = $attachment->create_thumbnail($this->max_thumbnail_width, $this->max_thumbnail_width === false ? false : 0);
// set first screenshot as preview image when it is uploaded
$is_preview = !$this->operator->get_count();
}
$attachment->__set_array(array('thumbnail' => $has_thumbnail, 'is_preview' => $is_preview));
$attachment->submit();
// Store in operator
$this->operator->set($attachment);
$this->uploaded = $attachment->get_id();
}
}
// We do not want to upload it again if this function is called again.
$this->request->overwrite($this->form_name, null, request_interface::FILES);
}
示例2: rfd_api_pre_update_topic
/**
* Event: rfd.api.pre_update_topic
*
* Validate trader_type being passed in
*
* @param phpbbEvent $event
*/
public function rfd_api_pre_update_topic(phpbbEvent $event)
{
$data = $event->get_data();
$topic_id = $data['topic_id'];
$forum_id = $data['forum_id'];
$errors = $data['errors'];
$type = $this->request->variable('trader_type', '', false, \phpbb\request\request_interface::POST);
// if trader_type is not set, set it to the current trader_type
if (!isset($type)) {
$type = $this->manager->getTopicType($topic_id);
$type = $this->manager->validateForumType($forum_id, $type, false);
} else {
if ($this->manager->getForumStatus($forum_id)) {
$type = $this->manager->validateForumType($forum_id, $type, true);
}
}
// Expose error if trader_type is not supported by the forum
if (is_null($type)) {
$errors[] = 'This forum does not support that trader type';
$data['errors'] = $errors;
$event->set_data($data);
} else {
// Overwrite the request so that submit_post_end listener can handle trader_type
$this->request->overwrite('prefixfield', $type, \phpbb\request\request_interface::POST);
}
}
示例3: local_upload
/**
* Move file from another location to phpBB
*
* @param string $source_file Filename of source file
* @param array|bool $filedata Array with filedata or false
*
* @return filespec Object "filespec" is returned, all further operations can be done with this object
*/
protected function local_upload($source_file, $filedata = false)
{
$upload = $this->get_upload_ary($source_file, $filedata);
/** @var filespec $file */
$file = $this->factory->get('filespec')->set_upload_ary($upload)->set_upload_namespace($this->upload);
if ($file->init_error()) {
$file->error[] = '';
return $file;
}
// PHP Upload file size check
$file = $this->check_upload_size($file);
if (sizeof($file->error)) {
return $file;
}
// Not correctly uploaded
if (!$file->is_uploaded()) {
$file->error[] = $this->language->lang($this->upload->error_prefix . 'NOT_UPLOADED');
return $file;
}
$this->upload->common_checks($file);
$this->request->overwrite('local', $upload, request_interface::FILES);
return $file;
}