<?php

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

class chunk_c_site extends CI_Model implements chunk_interface
{

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

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

                return FALSE;
            }
            $moduleName = strtolower($this->input->post('moduleName'));
            $source = str_replace(['CLASSNAME', 'MODULE'], [ucfirst($moduleName), $moduleName], file_get_contents($this->skeleton_model_admin->getSrcFolder() . '/controllers/site.php'));

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

}
