mourne_rcpp_fw/Mourne-CI/application/models/image_model.php

284 lines
8.3 KiB
PHP
Raw Normal View History

2021-10-30 19:02:07 +02:00
<?php
class Image_model extends MO_Model
{
public function __construct()
{
parent::__construct();
}
2021-10-30 19:02:07 +02:00
public function apply_menu_images($data)
{
$path = './img/generated/';
2021-10-30 19:02:07 +02:00
$this->load->library('image_lib');
2021-10-30 19:02:07 +02:00
if ($data['apply_all']) {
$this->prepare_dir('menu', $data['file'], $data['menu_group']);
} else {
$this->prepare_dir('menu', $data['file'], false, $data['wm_text']);
}
2021-10-30 19:02:07 +02:00
if (!$data['apply_all']) {
$data['source_image'] = $path . $data['wm_text'] . '.png';
2021-10-30 19:02:07 +02:00
$this->image_lib->initialize($data);
2021-10-30 19:02:07 +02:00
$this->image_lib->watermark();
2021-10-30 19:02:07 +02:00
return;
}
2021-10-30 19:02:07 +02:00
//apply all is set
$menu_list = $this->get_menu_list($data['menu_group']);
$menu_file_list = $this->get_menu_file_list($data['menu_group']);
2021-10-30 19:02:07 +02:00
for ($i = 0; $i < sizeof($menu_list); $i++) {
$data['source_image'] = $path . $menu_file_list[$i] . '.png';
$data['wm_text'] = $menu_list[$i];
2021-10-30 19:02:07 +02:00
$this->image_lib->initialize($data);
$this->image_lib->watermark();
$this->image_lib->clear();
}
2021-10-30 19:02:07 +02:00
}
public function prepare_dir($for, $sourcefile, $group = 1, $filename = false)
{
$path = './img/generated/';
$source = './img/imggen/' . $sourcefile;
2021-10-30 19:02:07 +02:00
$this->load->helper('file');
2021-10-30 19:02:07 +02:00
delete_files($path, false);
2021-10-30 19:02:07 +02:00
if ($for == 'menu') {
$img = read_file($source);
2021-10-30 19:02:07 +02:00
if (!$filename) {
$menu_list = $this->get_menu_file_list($group);
2021-10-30 19:02:07 +02:00
foreach ($menu_list as $row) {
$file = $path . $row . '.png';
2021-10-30 19:02:07 +02:00
write_file($file, $img);
}
} else {
$file = $path . $filename . '.png';
2021-10-30 19:02:07 +02:00
write_file($file, $img);
}
}
2021-10-30 19:02:07 +02:00
}
public function get_menu_list($group = 1)
2021-10-30 19:02:07 +02:00
{
if ($group == 1) {
//select village vill be omitted since it will need a different style button with a ˇ
$data[] = 'News';
$data[] = 'Village';
$data[] = 'Select Village';
$data[] = 'Forum';
$data[] = 'Changelog';
$data[] = 'Settings';
$data[] = 'Logout';
$data[] = 'Forum Mod Panel';
$data[] = 'GM Panel';
$data[] = 'Admin Panel';
}
if ($group == 2) {
$data[] = 'Stats';
}
return $data;
2021-10-30 19:02:07 +02:00
}
public function get_menu_file_list($group = 1)
{
if ($group == 1) {
//select village vill be omitted since it will need a different style button with a ˇ
$data[] = 'news';
$data[] = 'village';
$data[] = 'select_village';
$data[] = 'forum';
$data[] = 'changelog';
$data[] = 'settings';
$data[] = 'logout';
$data[] = 'forum_mod_panel';
$data[] = 'gm_panel';
$data[] = 'admin_panel';
}
if ($group == 2) {
$data[] = 'stats';
}
return $data;
}
2021-10-30 19:02:07 +02:00
public function get_menu_group_list_drop()
{
$data = array(
2021-10-30 19:02:07 +02:00
'1' => 'main',
'2' => 'alt1');
return $data;
}
2021-10-30 19:02:07 +02:00
public function apply_slot_images($data)
{
$path = './img/generated/';
2021-10-30 19:02:07 +02:00
$this->load->library('image_lib');
2021-10-30 19:02:07 +02:00
$this->prepare_dir('menu', $data['file'], false, 'gen');
2021-10-30 19:02:07 +02:00
$data['source_image'] = $path . 'gen.png';
2021-10-30 19:02:07 +02:00
$this->image_lib->initialize($data);
$this->image_lib->watermark();
$this->image_lib->clear();
2021-10-30 19:02:07 +02:00
$data['wm_type'] = 'text';
$data['wm_text'] = $data['rank_text'];
$data['wm_font_size'] = $data['rank_font_size'];
$data['wm_vrt_alignment'] = $data['rank_v_align'];
$data['wm_hor_alignment'] = $data['rank_h_align'];
$data['wm_hor_offset'] = $data['rank_h_offset'];
$data['wm_vrt_offset'] = $data['rank_v_offset'];
$data['padding'] = $data['rank_padding'];
2021-10-30 19:02:07 +02:00
$this->image_lib->initialize($data);
$this->image_lib->watermark();
}
2021-10-30 19:02:07 +02:00
public function get_file_list_drop()
{
$this->load->helper('directory');
2021-10-30 19:02:07 +02:00
$dir = directory_map('./img/imggen/', 1);
2021-10-30 19:02:07 +02:00
foreach ($dir as $row) {
$a = explode('.', $row);
if (isset($a[1])) {
if ($a[1] == 'png' || $a[1] == 'PNG') {
$data[$row] = $row;
}
}
}
2021-10-30 19:02:07 +02:00
return $data;
2021-10-30 19:02:07 +02:00
}
public function get_font_list_drop()
{
$this->load->helper('directory');
2021-10-30 19:02:07 +02:00
$dir = directory_map('./system/fonts', 1);
2021-10-30 19:02:07 +02:00
foreach ($dir as $row) {
$a = explode('.', $row);
2021-10-30 19:02:07 +02:00
if ($a[1] == 'ttf' || $a['1'] == 'TTF') {
$data[$row] = $row;
}
}
2021-10-30 19:02:07 +02:00
return $data;
2021-10-30 19:02:07 +02:00
}
public function get_v_align_drop()
{
$data = array(
2021-10-30 19:02:07 +02:00
'top' => 'top',
'middle' => 'middle',
'bottom' => 'bottom');
return $data;
}
2021-10-30 19:02:07 +02:00
public function get_h_align_drop()
{
$data = array(
2021-10-30 19:02:07 +02:00
'left' => 'left',
'center' => 'center',
'right' => 'right');
return $data;
}
public function get_overlay_list_drop()
{
$this->load->helper('directory');
$dir = directory_map('./img/imggen/overlay/', 1);
2021-10-30 19:02:07 +02:00
foreach ($dir as $row) {
$data[$row] = $row;
}
2021-10-30 19:02:07 +02:00
return $data;
}
public function save_menu_data($data)
2021-10-30 19:02:07 +02:00
{
$a = 'type : ' . $data['wm_type'] . "\n";
$a .= 'quality: ' . $data['quality'] . "\n";
$a .= 'file: ' . $data['file'] . "\n";
$a .= 'padding: ' . $data['padding'] . "\n";
$a .= 'vert alignment: ' . $data['wm_vrt_alignment'] . "\n";
$a .= 'hor alignment: ' . $data['wm_hor_alignment'] . "\n";
$a .= 'hor offset: ' . $data['wm_hor_offset'] . "\n";
$a .= 'vert offset: ' . $data['wm_vrt_offset'] . "\n";
$a .= 'text: ' . $data['wm_text'] . "\n";
$a .= 'font path: ' . $data['wm_font_path'] . "\n";
$a .= 'font size: ' . $data['wm_font_size'] . "\n";
$a .= 'font color: ' . $data['wm_font_color'] . "\n";
$a .= 'shadow color: ' . $data['wm_shadow_color'] . "\n";
$a .= 'shadow_distance: ' . $data['wm_shadow_distance'] . "\n";
$a .= 'apply all: ' . $data['apply_all'] . "\n";
$a .= 'Menu Group: ' . $data['menu_group'] . "\n";
$this->load->helper('file');
write_file('./img/generated/settings.txt', $a);
2021-10-30 19:02:07 +02:00
}
public function save_slot_data($data)
{
$a = 'type : ' . $data['wm_type'] . "\n";
$a .= 'quality: ' . $data['quality'] . "\n";
$a .= 'file: ' . $data['file'] . "\n";
$a .= 'padding: ' . $data['padding'] . "\n";
$a .= 'vert alignment: ' . $data['wm_vrt_alignment'] . "\n";
$a .= 'hor alignment: ' . $data['wm_hor_alignment'] . "\n";
$a .= 'hor offset: ' . $data['wm_hor_offset'] . "\n";
$a .= 'vert offset: ' . $data['wm_vrt_offset'] . "\n";
$a .= 'text: ' . $data['wm_text'] . "\n";
$a .= 'font path: ' . $data['wm_font_path'] . "\n";
$a .= 'font size: ' . $data['wm_font_size'] . "\n";
$a .= 'font color: ' . $data['wm_font_color'] . "\n";
$a .= 'shadow color: ' . $data['wm_shadow_color'] . "\n";
$a .= 'shadow_distance: ' . $data['wm_shadow_distance'] . "\n";
$a .= '------------------------image---------------------------' . "\n";
$a .= 'overlay image: ' . $data['wm_overlay_path'] . "\n";
$a .= 'opacity: ' . $data['wm_opacity'] . "\n";
$a .= 'x transp: ' . $data['wm_x_transp'] . "\n";
$a .= 'y transp: ' . $data['wm_y_transp'] . "\n";
$a .= '------------------------rank----------------------------' . "\n";
$a .= 'text: ' . $data['rank_text'] . "\n";
$a .= 'font size: ' . $data['rank_font_size'] . "\n";
$a .= 'V align: ' . $data['rank_v_align'] . "\n";
$a .= 'H align: ' . $data['rank_h_align'] . "\n";
$a .= 'H offset: ' . $data['rank_h_offset'] . "\n";
$a .= 'V offset: ' . $data['rank_v_offset'] . "\n";
$a .= 'padding: ' . $data['rank_padding'] . "\n";
$this->load->helper('file');
write_file('./img/generated/settings.txt', $a);
}
2021-10-30 19:02:07 +02:00
}
//nowhitesp