Database logic additions

- Migration script to create default values
- Corrected naming of variables in general_config.php
- Replaced hardcoded values with db variables
This commit is contained in:
objecttothis
2020-05-08 14:22:49 +04:00
parent a79e9dd4cb
commit 59142d9f69
3 changed files with 35 additions and 10 deletions

View File

@@ -669,13 +669,11 @@ class Items extends Secure_Controller
{
//Load upload library
$config = array('upload_path' => './uploads/item_pics/',
'allowed_types' => 'gif|jpg|png',
'max_size' => '100',
'max_width' => '640',
'max_height' => '480'
);
$this->load->library('upload', $config);
'allowed_types' => $this->config->item('image_allowed_types'),
'max_size' => $this->config->item('image_max_size'),
'max_width' => $this->config->item('image_max_width'),
'max_height' => $this->config->item('image_max_height'));
$this->load->library('upload', $config);
$this->upload->do_upload('item_image');
return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');

View File

@@ -0,0 +1,27 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Migration_image_upload_defaults extends CI_Migration
{
public function __construct()
{
parent::__construct();
}
public function up()
{
$image_values = array(
array('key' => 'allowed_types', 'value' => 'gif|jpg|png'),
array('key' => 'max_height', 'value' => '480'),
array('key' => 'max_size', 'value' => '100'),
array('key' => 'max_width', 'value' => '640'));
$this->db->insert_batch('app_config', $image_values);
}
public function down()
{
$this->db->where_in('key', array('allowed_types','max_height','max_size','max_width'));
$this->db->delete('app_config');
}
}
?>

View File

@@ -143,7 +143,7 @@
'type' => 'number',
'min' => 128,
'max' => 3840,
'value' => $this->config->item('max_image_width'),
'value' => $this->config->item('image_max_width'),
'data-toggle' => 'tooltip',
'data-placement' => 'top',
'title' => $this->lang->line('config_image_max_width_tooltip')));
@@ -160,7 +160,7 @@
'type' => 'number',
'min' => 128,
'max' => 3840,
'value' => $this->config->item('max_image_height'),
'value' => $this->config->item('image_max_height'),
'data-toggle' => 'tooltip',
'data-placement' => 'top',
'title' => $this->lang->line('config_image_max_height_tooltip')));
@@ -177,7 +177,7 @@
'type' => 'number',
'min' => 128,
'max' => 2048,
'value' => $this->config->item('max_image_size'),
'value' => $this->config->item('image_max_size'),
'data-toggle' => 'tooltip',
'data-placement' => 'top',
'title' => $this->lang->line('config_image_max_size_tooltip')));