| @@ 14-199 (lines=186) @@ | ||
| 11 | * @property CI_Loader load |
|
| 12 | * @property CI_DB_forge dbforge |
|
| 13 | */ |
|
| 14 | class Gallery_install extends CI_Model |
|
| 15 | { |
|
| 16 | ||
| 17 | public function __construct() { |
|
| 18 | ||
| 19 | parent::__construct(); |
|
| 20 | } |
|
| 21 | ||
| 22 | public function make_install() { |
|
| 23 | ||
| 24 | // Enable url access and install default settings |
|
| 25 | ||
| 26 | $params = [ |
|
| 27 | 'max_image_size' => 5, |
|
| 28 | 'max_width' => 0, |
|
| 29 | 'max_height' => 0, |
|
| 30 | 'quality' => 95, |
|
| 31 | 'maintain_ratio' => TRUE, |
|
| 32 | 'maintain_ratio_prev' => TRUE, |
|
| 33 | 'maintain_ratio_icon' => TRUE, |
|
| 34 | 'prev_img_width' => 500, |
|
| 35 | 'prev_img_height' => 500, |
|
| 36 | 'thumb_width' => 100, |
|
| 37 | 'thumb_height' => 100, |
|
| 38 | 'watermark_text' => '', |
|
| 39 | 'wm_vrt_alignment' => 'bottom', |
|
| 40 | 'wm_hor_alignment' => 'right', |
|
| 41 | 'watermark_font_size' => '14', |
|
| 42 | 'watermark_color' => 'ffffff', |
|
| 43 | 'watermark_padding' => '-5', |
|
| 44 | 'watermark_font_path' => './uploads/defaultFont.ttf', |
|
| 45 | 'order_by' => 'date', |
|
| 46 | 'sort_order' => 'desc', |
|
| 47 | 'watermark_type' => 'text', |
|
| 48 | 'watermark_image_opacity' => 50, |
|
| 49 | ]; |
|
| 50 | ||
| 51 | $this->db->where('name', 'gallery'); |
|
| 52 | $this->db->update('components', ['enabled' => 1, 'settings' => serialize($params)]); |
|
| 53 | ||
| 54 | $this->load->dbforge(); |
|
| 55 | ||
| 56 | /* Albums table */ |
|
| 57 | $fields = [ |
|
| 58 | 'id' => [ |
|
| 59 | 'type' => 'INT', |
|
| 60 | 'constraint' => 11, |
|
| 61 | 'auto_increment' => TRUE, |
|
| 62 | ], |
|
| 63 | 'category_id' => [ |
|
| 64 | 'type' => 'INT', |
|
| 65 | 'constraint' => 11, |
|
| 66 | ], |
|
| 67 | 'name' => [ |
|
| 68 | 'type' => 'VARCHAR', |
|
| 69 | 'constraint' => 250, |
|
| 70 | ], |
|
| 71 | 'description' => [ |
|
| 72 | 'type' => 'VARCHAR', |
|
| 73 | 'constraint' => 500, |
|
| 74 | ], |
|
| 75 | 'cover_id' => [ |
|
| 76 | 'type' => 'INT', |
|
| 77 | 'constraint' => 11, |
|
| 78 | 'default' => 0, |
|
| 79 | ], |
|
| 80 | 'position' => [ |
|
| 81 | 'type' => 'INT', |
|
| 82 | 'constraint' => 9, |
|
| 83 | 'default' => 0, |
|
| 84 | ], |
|
| 85 | 'created' => [ |
|
| 86 | 'type' => 'INT', |
|
| 87 | 'constraint' => 11, |
|
| 88 | ], |
|
| 89 | 'updated' => [ |
|
| 90 | 'type' => 'INT', |
|
| 91 | 'constraint' => 11, |
|
| 92 | ], |
|
| 93 | 'tpl_file' => [ |
|
| 94 | 'type' => 'VARCHAR', |
|
| 95 | 'constraint' => 200, |
|
| 96 | ], |
|
| 97 | ]; |
|
| 98 | ||
| 99 | $this->dbforge->add_key('id', TRUE); |
|
| 100 | $this->dbforge->add_field($fields); |
|
| 101 | $this->dbforge->create_table('gallery_albums', TRUE); |
|
| 102 | ||
| 103 | /* Images table */ |
|
| 104 | $fields2 = [ |
|
| 105 | 'id' => [ |
|
| 106 | 'type' => 'INT', |
|
| 107 | 'constraint' => 11, |
|
| 108 | 'auto_increment' => TRUE, |
|
| 109 | ], |
|
| 110 | 'album_id' => [ |
|
| 111 | 'type' => 'INT', |
|
| 112 | 'constraint' => 11, |
|
| 113 | ], |
|
| 114 | 'file_name' => [ |
|
| 115 | 'type' => 'VARCHAR', |
|
| 116 | 'constraint' => 150, |
|
| 117 | ], |
|
| 118 | 'file_ext' => [ |
|
| 119 | 'type' => 'VARCHAR', |
|
| 120 | 'constraint' => 8, |
|
| 121 | ], |
|
| 122 | 'file_size' => [ |
|
| 123 | 'type' => 'VARCHAR', |
|
| 124 | 'constraint' => 20, |
|
| 125 | ], |
|
| 126 | 'position' => [ |
|
| 127 | 'type' => 'INT', |
|
| 128 | 'constraint' => 9, |
|
| 129 | ], |
|
| 130 | 'width' => [ |
|
| 131 | 'type' => 'INT', |
|
| 132 | 'constraint' => 6, |
|
| 133 | ], |
|
| 134 | 'height' => [ |
|
| 135 | 'type' => 'INT', |
|
| 136 | 'constraint' => 6, |
|
| 137 | ], |
|
| 138 | 'description' => [ |
|
| 139 | 'type' => 'VARCHAR', |
|
| 140 | 'constraint' => 500, |
|
| 141 | ], |
|
| 142 | 'uploaded' => [ |
|
| 143 | 'type' => 'INT', |
|
| 144 | 'constraint' => 11, |
|
| 145 | ], |
|
| 146 | 'views' => [ |
|
| 147 | 'type' => 'INT', |
|
| 148 | 'constraint' => 11, |
|
| 149 | ], |
|
| 150 | ]; |
|
| 151 | ||
| 152 | $this->dbforge->add_key('id', TRUE); |
|
| 153 | $this->dbforge->add_field($fields2); |
|
| 154 | $this->dbforge->create_table('gallery_images', TRUE); |
|
| 155 | ||
| 156 | /* Categories table */ |
|
| 157 | $category = [ |
|
| 158 | 'id' => [ |
|
| 159 | 'type' => 'INT', |
|
| 160 | 'constraint' => 11, |
|
| 161 | 'auto_increment' => TRUE, |
|
| 162 | ], |
|
| 163 | 'name' => [ |
|
| 164 | 'type' => 'VARCHAR', |
|
| 165 | 'constraint' => 250, |
|
| 166 | ], |
|
| 167 | 'description' => [ |
|
| 168 | 'type' => 'VARCHAR', |
|
| 169 | 'constraint' => 500, |
|
| 170 | ], |
|
| 171 | 'cover_id' => [ |
|
| 172 | 'type' => 'INT', |
|
| 173 | 'constraint' => 11, |
|
| 174 | 'default' => 0, |
|
| 175 | ], |
|
| 176 | 'position' => [ |
|
| 177 | 'type' => 'INT', |
|
| 178 | 'constraint' => 9, |
|
| 179 | 'default' => 0, |
|
| 180 | ], |
|
| 181 | 'created' => [ |
|
| 182 | 'type' => 'INT', |
|
| 183 | 'constraint' => 11, |
|
| 184 | ], |
|
| 185 | ]; |
|
| 186 | ||
| 187 | $this->dbforge->add_key('id', TRUE); |
|
| 188 | $this->dbforge->add_field($category); |
|
| 189 | $this->dbforge->create_table('gallery_category', TRUE); |
|
| 190 | } |
|
| 191 | ||
| 192 | public function deinstall() { |
|
| 193 | $this->load->dbforge(); |
|
| 194 | $this->dbforge->drop_table('gallery_albums'); |
|
| 195 | $this->dbforge->drop_table('gallery_images'); |
|
| 196 | $this->dbforge->drop_table('gallery_category'); |
|
| 197 | } |
|
| 198 | ||
| 199 | } |
|
| 200 | ||
| 201 | /* End of file install.php */ |
|
| @@ 12-197 (lines=186) @@ | ||
| 9 | * |
|
| 10 | * Gallery main model |
|
| 11 | */ |
|
| 12 | class Install extends CI_Model { |
|
| 13 | ||
| 14 | public function __construct() { |
|
| 15 | ||
| 16 | parent::__construct(); |
|
| 17 | } |
|
| 18 | ||
| 19 | public function make_install() { |
|
| 20 | ||
| 21 | // Enable url access and install default settings |
|
| 22 | ||
| 23 | $params = array( |
|
| 24 | 'max_image_size' => 5, |
|
| 25 | 'max_width' => 0, |
|
| 26 | 'max_height' => 0, |
|
| 27 | 'quality' => 95, |
|
| 28 | 'maintain_ratio' => TRUE, |
|
| 29 | 'maintain_ratio_prev' => TRUE, |
|
| 30 | 'maintain_ratio_icon' => TRUE, |
|
| 31 | 'prev_img_width' => 500, |
|
| 32 | 'prev_img_height' => 500, |
|
| 33 | 'thumb_width' => 100, |
|
| 34 | 'thumb_height' => 100, |
|
| 35 | 'watermark_text' => '', |
|
| 36 | 'wm_vrt_alignment' => 'bottom', |
|
| 37 | 'wm_hor_alignment' => 'right', |
|
| 38 | 'watermark_font_size' => '14', |
|
| 39 | 'watermark_color' => 'ffffff', |
|
| 40 | 'watermark_padding' => '-5', |
|
| 41 | 'watermark_font_path' => './uploads/defaultFont.ttf', |
|
| 42 | 'order_by' => 'date', |
|
| 43 | 'sort_order' => 'desc', |
|
| 44 | 'watermark_type' => 'text', |
|
| 45 | 'watermark_image_opacity' => 50, |
|
| 46 | ); |
|
| 47 | ||
| 48 | $this->db->where('name', 'gallery'); |
|
| 49 | $this->db->update('components', array('enabled' => 1, 'settings' => serialize($params))); |
|
| 50 | ||
| 51 | $this->load->dbforge(); |
|
| 52 | ||
| 53 | /* Albums table */ |
|
| 54 | $fields = array( |
|
| 55 | 'id' => array( |
|
| 56 | 'type' => 'INT', |
|
| 57 | 'constraint' => 11, |
|
| 58 | 'auto_increment' => TRUE, |
|
| 59 | ), |
|
| 60 | 'category_id' => array( |
|
| 61 | 'type' => 'INT', |
|
| 62 | 'constraint' => 11, |
|
| 63 | ), |
|
| 64 | 'name' => array( |
|
| 65 | 'type' => 'VARCHAR', |
|
| 66 | 'constraint' => 250, |
|
| 67 | ), |
|
| 68 | 'description' => array( |
|
| 69 | 'type' => 'VARCHAR', |
|
| 70 | 'constraint' => 500, |
|
| 71 | ), |
|
| 72 | 'cover_id' => array( |
|
| 73 | 'type' => 'INT', |
|
| 74 | 'constraint' => 11, |
|
| 75 | 'default' => 0, |
|
| 76 | ), |
|
| 77 | 'position' => array( |
|
| 78 | 'type' => 'INT', |
|
| 79 | 'constraint' => 9, |
|
| 80 | 'default' => 0, |
|
| 81 | ), |
|
| 82 | 'created' => array( |
|
| 83 | 'type' => 'INT', |
|
| 84 | 'constraint' => 11, |
|
| 85 | ), |
|
| 86 | 'updated' => array( |
|
| 87 | 'type' => 'INT', |
|
| 88 | 'constraint' => 11, |
|
| 89 | ), |
|
| 90 | 'tpl_file' => array( |
|
| 91 | 'type' => 'VARCHAR', |
|
| 92 | 'constraint' => 200, |
|
| 93 | ), |
|
| 94 | ); |
|
| 95 | ||
| 96 | $this->dbforge->add_key('id', TRUE); |
|
| 97 | $this->dbforge->add_field($fields); |
|
| 98 | $this->dbforge->create_table('gallery_albums', TRUE); |
|
| 99 | ||
| 100 | /* Images table */ |
|
| 101 | $fields2 = array( |
|
| 102 | 'id' => array( |
|
| 103 | 'type' => 'INT', |
|
| 104 | 'constraint' => 11, |
|
| 105 | 'auto_increment' => TRUE, |
|
| 106 | ), |
|
| 107 | 'album_id' => array( |
|
| 108 | 'type' => 'INT', |
|
| 109 | 'constraint' => 11, |
|
| 110 | ), |
|
| 111 | 'file_name' => array( |
|
| 112 | 'type' => 'VARCHAR', |
|
| 113 | 'constraint' => 150, |
|
| 114 | ), |
|
| 115 | 'file_ext' => array( |
|
| 116 | 'type' => 'VARCHAR', |
|
| 117 | 'constraint' => 8, |
|
| 118 | ), |
|
| 119 | 'file_size' => array( |
|
| 120 | 'type' => 'VARCHAR', |
|
| 121 | 'constraint' => 20, |
|
| 122 | ), |
|
| 123 | 'position' => array( |
|
| 124 | 'type' => 'INT', |
|
| 125 | 'constraint' => 9, |
|
| 126 | ), |
|
| 127 | 'width' => array( |
|
| 128 | 'type' => 'INT', |
|
| 129 | 'constraint' => 6, |
|
| 130 | ), |
|
| 131 | 'height' => array( |
|
| 132 | 'type' => 'INT', |
|
| 133 | 'constraint' => 6, |
|
| 134 | ), |
|
| 135 | 'description' => array( |
|
| 136 | 'type' => 'VARCHAR', |
|
| 137 | 'constraint' => 500, |
|
| 138 | ), |
|
| 139 | 'uploaded' => array( |
|
| 140 | 'type' => 'INT', |
|
| 141 | 'constraint' => 11, |
|
| 142 | ), |
|
| 143 | 'views' => array( |
|
| 144 | 'type' => 'INT', |
|
| 145 | 'constraint' => 11, |
|
| 146 | ), |
|
| 147 | ); |
|
| 148 | ||
| 149 | $this->dbforge->add_key('id', TRUE); |
|
| 150 | $this->dbforge->add_field($fields2); |
|
| 151 | $this->dbforge->create_table('gallery_images', TRUE); |
|
| 152 | ||
| 153 | /* Categories table */ |
|
| 154 | $category = array( |
|
| 155 | 'id' => array( |
|
| 156 | 'type' => 'INT', |
|
| 157 | 'constraint' => 11, |
|
| 158 | 'auto_increment' => TRUE, |
|
| 159 | ), |
|
| 160 | 'name' => array( |
|
| 161 | 'type' => 'VARCHAR', |
|
| 162 | 'constraint' => 250, |
|
| 163 | ), |
|
| 164 | 'description' => array( |
|
| 165 | 'type' => 'VARCHAR', |
|
| 166 | 'constraint' => 500, |
|
| 167 | ), |
|
| 168 | 'cover_id' => array( |
|
| 169 | 'type' => 'INT', |
|
| 170 | 'constraint' => 11, |
|
| 171 | 'default' => 0, |
|
| 172 | ), |
|
| 173 | 'position' => array( |
|
| 174 | 'type' => 'INT', |
|
| 175 | 'constraint' => 9, |
|
| 176 | 'default' => 0, |
|
| 177 | ), |
|
| 178 | 'created' => array( |
|
| 179 | 'type' => 'INT', |
|
| 180 | 'constraint' => 11, |
|
| 181 | ), |
|
| 182 | ); |
|
| 183 | ||
| 184 | $this->dbforge->add_key('id', TRUE); |
|
| 185 | $this->dbforge->add_field($category); |
|
| 186 | $this->dbforge->create_table('gallery_category', TRUE); |
|
| 187 | } |
|
| 188 | ||
| 189 | public function deinstall() { |
|
| 190 | ||
| 191 | $this->load->dbforge(); |
|
| 192 | $this->dbforge->drop_table('gallery_albums'); |
|
| 193 | $this->dbforge->drop_table('gallery_images'); |
|
| 194 | $this->dbforge->drop_table('gallery_category'); |
|
| 195 | } |
|
| 196 | ||
| 197 | } |
|
| 198 | ||
| 199 | /* End of file install.php */ |
|