Example #1
0
 public function login()
 {
     $this->form_validation->set_rules('email', 'E-mail', 'required|valid_email');
     $this->form_validation->set_rules('senha', 'Senha', 'required');
     if ($this->form_validation->run()) {
         $email = $this->input->post('email', true);
         $senha = md5($this->input->post('senha', true));
         if ($this->users_model->login($email, $senha)) {
             $query = $this->users_model->getUser($email)->row();
             $userData = array('id' => $query->id, 'nome' => $query->nome, 'email' => $email, 'admin' => $query->admin, 'logged' => true);
             $this->session->set_userdata($userData);
             redirect('painel');
         } else {
             echo '<span id="fail" data-fail="login"></span>';
         }
     }
     setTheme('title', 'Login');
     setTheme('content', loadModule('user', 'login'));
     setTheme('initPlugins', loadJavascript(array('scripts/user-pages')), false);
     setTheme('bodyClass', 'login bg-login printable');
     loadTemplate();
 }
function initAdmin()
{
    $ci =& get_instance();
    $ci->load->library(array('system', 'session', 'form_validation'));
    $ci->load->helper(array('form', 'url', 'array', 'text'));
    $ci->load->model(array('users_model'));
    // Models
    setTheme('defaultTitle', 'My Dashboard');
    setTheme('defaultSubtitle', 'Almost Everything!');
    $year = date('Y');
    setTheme('defaultFooter', "");
    setTheme('template', 'painel');
    setTheme('templateFolder', 'templates');
    // Header Globals
    setTheme('coreCSS', loadStyle(array('admin', 'elements', 'main', 'perfect-scrollbar')), false);
    setTheme('pluginsCSS', loadStyle(array('plugins')), false);
    setTheme('headerJS', loadJavascript(array('modernizr.min')), false);
    setTheme('headerIncludes', loadStyle(array('ionicons.min', 'font-awesome.min', 'Lobibox.min', 'animate')), false);
    // Footer Globals
    setTheme('globalVendors', loadJavascript(array('global-vendors')), false);
    setTheme('pluginsArea', '', false);
    setTheme('initPlugins', '', false);
    setTheme('footerIncludes', loadJavascript(array('pleasure', 'layout', 'bootstrap.min', 'perfect-scrollbar.jquery', 'lobibox.min', 'notifications.min', 'main')), false);
}
function consolidateFiles($info, $themes, $minify)
{
    $info = doInheritance($info, $themes);
    //print_r($info);
    //merge css files
    $fileGeneratedFile = $info['path'] . 'css/consolidated.min.css';
    $fileGeneratedFileHnd = fopen($fileGeneratedFile, 'w');
    foreach ($info['settings']['css'] as $filename => $scope) {
        if ($filename == 'extra_styles.css') {
            continue;
        }
        //Load contents from the search file
        $fileContents = loadCss($filename, $info['searchPaths']);
        if ($fileContents != null) {
            fwrite($fileGeneratedFileHnd, "/* {$filename} */\r\n");
            //minify the css
            if ($minify && !preg_match('/.*\\.min\\.css$/i', $filename)) {
                $minifiedCss = Minify_CSS::minify($fileContents, array());
            } else {
                $minifiedCss = $fileContents;
            }
            fwrite($fileGeneratedFileHnd, "{$minifiedCss}\r\n");
        } else {
            echo "Could not find file {$filename}";
        }
    }
    //Add extra_styles.css at the very end
    $filename = 'extra_styles.css';
    $fileContents = loadCss($filename, $info['searchPaths']);
    if ($fileContents != null) {
        fwrite($fileGeneratedFileHnd, "/* {$filename} */\r\n");
        //minify the css
        if ($minify && !preg_match('/.*\\.min\\.css$/i', $filename)) {
            $minifiedCss = Minify_CSS::minify($fileContents, array());
        } else {
            $minifiedCss = $fileContents;
        }
        fwrite($fileGeneratedFileHnd, "{$minifiedCss}\r\n");
    }
    fclose($fileGeneratedFileHnd);
    //merge javascript files
    $fileGeneratedFile = $info['path'] . 'js/consolidated.min.js';
    if (!file_exists($info['path'] . 'js')) {
        mkdir($info['path'] . 'js', true);
    }
    $fileGeneratedFileHnd = fopen($fileGeneratedFile, 'w');
    foreach ($info['settings']['javascript'] as $filename => $scope) {
        //echo("Consolidating  $filename<br/>");
        //Load contents from the search file
        $fileContents = loadJavascript($filename, $info['searchPaths']);
        if ($fileContents != null) {
            fwrite($fileGeneratedFileHnd, "/* {$filename} */\r\n");
            //minify the javascript
            if ($minify && !preg_match('/.*\\.min\\.js$/i', $filename)) {
                $minifiedJs = JSMin::minify($fileContents);
            } else {
                $minifiedJs = $fileContents;
            }
            fwrite($fileGeneratedFileHnd, "{$minifiedJs}\r\n");
        } else {
            echo "Could not find file {$filename}";
        }
    }
    fclose($fileGeneratedFileHnd);
}