本文整理汇总了PHP中kohana::find_file方法的典型用法代码示例。如果您正苦于以下问题:PHP kohana::find_file方法的具体用法?PHP kohana::find_file怎么用?PHP kohana::find_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kohana
的用法示例。
在下文中一共展示了kohana::find_file方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_login
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: before
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: index
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: css
/**
* 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: defined
<?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:
<?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();