<?php

if (!defined('BASEPATH')) {
    exit('No direct script access allowed');
}

class chunk_v_site extends CI_Model implements chunk_interface
{

    public function get_admin_html()
    {
        return '<div class="control-group"><div class="controls">'
                . form_checkbox('create_v_site_file', '1', $this->input->post('create_v_site_file')) . ' ' . $this->lang->line('Create site view dummy')
                . '</div></div>';
    }

    public function run()
    {
        // Create install controller
        if ($this->input->post('create_v_site_file')) {
            $folder = $this->skeleton_model_admin->getModuleFolder() . '/views';
            if (!$this->skeleton_model_admin->createFolder($folder)) {

                return FALSE;
            }
            $moduleName = $this->input->post('moduleName');
            $source = str_replace('MODULE', $moduleName, file_get_contents($this->skeleton_model_admin->getSrcFolder() . '/views/template.php'));

            return $this->skeleton_model_admin->createFile($folder . '/template.php', $source);
        }
    }

}
