コード例 #1
0
ファイル: admin.php プロジェクト: MenZil-Team/cms
 public function action_login()
 {
     if ($this->_auth->logged_in()) {
         // redirect to the user account
         $this->request->redirect(Route::get('admin')->uri(), 200);
     }
     // Disable sidebars on login page
     $this->_sidebars = FALSE;
     $this->title = __('Sign In');
     $user = ORM::factory('user');
     // Create form action
     $destination = isset($_GET['destination']) ? $_GET['destination'] : 'admin';
     $params = array('action' => 'login');
     $action = Route::get('admin/login')->uri($params) . URL::query(array('destination' => $destination));
     if ($layout = kohana::find_file('views', 'layouts/login')) {
         $this->template->set_filename('layouts/login');
     }
     $view = View::factory('admin/login')->set('use_username', Config::get('auth.username'))->set('post', $user)->set('action', $action)->bind('errors', $this->_errors);
     if ($this->valid_post('login')) {
         try {
             // Check Auth
             $user->login($this->request->post());
             // If the post data validates using the rules setup in the user model
             Message::success(__('Welcome, %title!', array('%title' => $user->nick)));
             Log::info('User :name logged in.', array(':name' => $user->name));
             // redirect to the user account
             $this->request->redirect(isset($_GET['destination']) ? $_GET['destination'] : 'admin', 200);
         } catch (Validation_Exception $e) {
             $this->_errors = $e->array->errors('login', TRUE);
         }
     }
     $this->response->body($view);
 }
コード例 #2
0
ファイル: page.php プロジェクト: bluehawk/kohanaphp.com
 public function before()
 {
     parent::before();
     $lang = $this->request->param('lang');
     // Make sure we have a valid language
     if (!in_array($lang, array_keys(Kohana::config('kohana')->languages))) {
         $this->request->action = 'error';
         throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri (specified language was not found in config)', array(':uri' => $this->request->uri));
     }
     I18n::$lang = $lang;
     if (isset($this->page_titles[$this->request->action])) {
         // Use the defined page title
         $title = $this->page_titles[$this->request->action];
     } else {
         // Use the page name as the title
         $title = ucwords(str_replace('_', ' ', $this->request->action));
     }
     $this->template->title = $title;
     if (!kohana::find_file('views', 'pages/' . $this->request->action)) {
         $this->request->action = 'error';
     }
     $this->template->content = View::factory('pages/' . $this->request->action);
     $this->template->set_global('request', $this->request);
     $this->template->meta_tags = array();
 }
コード例 #3
0
ファイル: sass.php プロジェクト: plusjade/plusjade
 public function index($file)
 {
     if (empty($file)) {
         die('no file');
     }
     header("Content-type: text/css");
     header("Pragma: public");
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     $file = kohana::find_file('views', "sass/{$file}", false, 'sass');
     # public_blog/blogs/stock
     if (!file_exists($file)) {
         die('invalid file');
     }
     # echo kohana::debug(file($file)); die();
     #$files = 'advanced';
     #if (!is_array($files)) $files = array($files);
     echo Kosass::factory('compact')->compile(file($file));
     # output directly to battle-test this sucka
     # echo sass::stylesheet('advanced', 'compact');
     die;
 }
コード例 #4
0
ファイル: site.php プロジェクト: artbypravesh/morningpages
 /**
  * Compiles .less files, joins and serves CSS.
  * @param Array css files.
  * @param bool Cache the files?
  */
 public static function css(array $files, $cache = true)
 {
     require_once kohana::find_file('vendor', 'lessphp/lessc.inc', 'php');
     $cssname = md5(implode('', $files)) . '.css';
     if ($cache && !file_exists(url::site('media/cache/' . $cssname, 'http')) || !$cache) {
         $content = '';
         foreach ($files as $file) {
             if (strpos($file, 'http') !== false || file_exists($file)) {
                 if (strpos($file, '.less') !== false) {
                     // It's a LESS file that we need to compile
                     $less = @file_get_contents($file);
                     $compiler = new lessc();
                     $content .= $compiler->parse($less);
                 } else {
                     $content .= @file_get_contents($file);
                 }
             }
         }
         file_put_contents('media/cache/' . $cssname, $content);
         unset($content);
     }
     return HTML::style('media/cache/' . $cssname);
 }
コード例 #5
0
<?php

defined('SYSPATH') or die('No direct script access.');
require_once kohana::find_file('helpers', 'response');
class NonLoginController_Core extends Controller
{
    function __construct()
    {
        parent::__construct();
        $this->session = Session::instance();
    }
}
?>


コード例 #6
0
ファイル: field.php プロジェクト: halka139/kohana_webdb
<?php

$view_file = kohana::find_file('views/fields', $column->get_type());
if ($view_file) {
    $field_view = View::factory('fields/' . $column->get_type());
} else {
    $field_view = View::factory('fields/varchar');
}
$field_view->column = $column;
$field_view->row = $row;
$field_view->edit = $edit;
$field_view->form_field_name = $form_field_name;
echo $field_view->render();