本文整理汇总了PHP中Website::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Website::instance方法的具体用法?PHP Website::instance怎么用?PHP Website::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Website
的用法示例。
在下文中一共展示了Website::instance方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_index
public function action_index()
{
// get acl
$acl = Acl::instance();
// get modules
$modules = Settings::factory('modules')->as_array();
// get navigation
$settings = Settings::factory('navigation', array('settings' . DIRECTORY_SEPARATOR . Website::instance()->id() . DIRECTORY_SEPARATOR, 'settings'));
$navigation = $settings->get('menu');
// filter out allowed modules
$allowedModules = array();
foreach ($modules as $module => $data) {
if ($acl->allowed($module, 'access')) {
$allowedModules[$module] = $data;
}
}
// fill up sections
$sections = array();
foreach ($navigation as $section => $modules) {
foreach ($modules as $module) {
if (isset($allowedModules[$module])) {
// section has a allowed module, so include it
if (!isset($sections[$section])) {
$sections[$section] = array();
}
// add module to section
$sections[$section][$module] = $allowedModules[$module];
}
}
}
$view = View::factory('start', array('sections' => $sections));
$this->response->body($view->render());
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:33,代码来源:Start.php
示例2: init
/**
* init: check if user is logged in
*
* if not: redirect to login
*/
public function init()
{
// call parent before first
parent::init();
// only check if the controller is not auth
if (Request::initial()->controller() != 'Auth') {
// url to loginpage
$url = URL::to('Auth@login');
// init identity
$identity = Identity::instance();
//revert identity to original user (maybe assume was called somewhere else)
$identity->revert();
// check authentication
if (!$identity->authenticated()) {
// if user is not allready authenticated, redirect to login page
$this->redirect($url);
} else {
$website = Website::instance();
// else: initialise acl
Acl::init($identity, new Model_Rights($website->websites()));
// set current environment
Acl::environment($website->id());
// if user is not entitled to access backend
if (!Acl::instance()->allowed('Backend', 'access')) {
$this->redirect($url);
}
// if user is not entitled to access controller
if (!Acl::instance()->allowed(Request::initial()->controller(), 'access')) {
$this->redirect($url);
}
}
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:38,代码来源:Auth.php
示例3: init
/**
* init
*/
public function init()
{
// raise event
Event::raise($this, Event::BEFORE_INIT);
// get website and feed it the current uri so we can figure out the ->id()
$website = Website::instance()->uri(Request::initial()->uri());
// set controller vars
$this->_website = $website->id();
$this->_directory = Request::current()->directory();
$this->_controller = Request::current()->controller();
$this->_action = Request::current()->action();
$this->_language = isset(Identity::instance()->user) ? Identity::instance()->user->language : 'nl';
// manually set website in Website
// this will be used by alias
Website::instance()->id($this->_website);
// set state session
// get state instance for this website / controller
State::session(Session::instance('database'));
$this->_state = State::instance($this->_website . '.' . $this->_controller);
// set route in URL helper
URL::route('backend');
// Let Filereader cache results
Reader::cache(Cache::instance('reader_backend'), 'backend');
// set default language
Text::language($this->_language);
// get that language's text instance and configure it
Text::instance($this->_language)->load(array_keys(Settings::factory('modules')->as_array()))->group($this->_controller)->substitutes('module');
// set URL presets
$base = URL::base();
URL::set('base', $base);
URL::set('library', $base . 'library/');
URL::set('vendor', $base . 'vendor/');
URL::set('files', $base . 'files/');
// set website in view
View::set_global('_website', $this->_website);
// set language in view
View::set_global('_language', $this->_language);
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:41,代码来源:Base.php
示例4: handle_item_before_update_form_parse
/**
* before parse form
*
* @param Model $model
* @param Form $form
*/
public function handle_item_before_update_form_parse($data)
{
// if there is only a global alias
// get that an show it in the form
if ($this->_settings->get('alias.global') == TRUE) {
$data->form->value('alias', Alias::factory(Website::instance()->id())->uris(array('controller' => $this->_controller, 'action' => 'view', 'id' => $data->model->id), FALSE));
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:14,代码来源:Item.php
示例5: action_top
/**
* create the top navigation
*/
public function action_top()
{
// get acl
$acl = Acl::instance();
// get websites
$websites = array();
foreach (Kohana::$config->load('websites')->websites as $key => $website) {
if ($acl->allowed('Environment', 'access', FALSE, $key)) {
$websites[$key] = $website;
}
}
// get modules
$modules = Settings::factory('modules')->as_array();
// get settings
$settings = Settings::factory('navigation', array('settings' . DIRECTORY_SEPARATOR . Website::instance()->id() . DIRECTORY_SEPARATOR, 'settings'));
// get navigation
$navigation = $settings->get('menu');
// get current controller
$controller = Request::initial()->controller();
// filter out allowed modules
$allowedModules = array();
foreach ($modules as $module => $data) {
if ($acl->allowed($module, 'access')) {
$allowedModules[$module] = TRUE;
}
}
// create a nested array with sections => modules
// catch active section
$sections = array();
$sectionActive = FALSE;
foreach ($navigation as $section => $modules) {
foreach ($modules as $module) {
if (isset($allowedModules[$module])) {
// section has a allowed module, so include it
if (!isset($sections[$section])) {
$sections[$section] = array();
}
// add module to section
$sections[$section][] = $module;
// check if this is the active section
if ($module === $controller) {
$sectionActive = $section;
}
}
}
}
// store active section
if ($sectionActive) {
// get current website
State::instance()->set('active.section', $sectionActive);
}
// check if frontendlink should be shown
if ($settings->get('frontend')) {
$frontend = URL::to('', array('website' => Website::instance()->id(), 'query' => 'edit=1'), 'frontend', Website::instance());
} else {
$frontend = FALSE;
}
// create view
$view = View::factory('navigation/top', array('acl' => $acl, 'websites' => $websites, 'sections' => $sections, 'active' => $sectionActive, 'website' => Website::instance()->id(), 'frontend' => $frontend));
// render view
$this->response->body($view->render());
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:65,代码来源:Navigation.php
示例6: action_embed
/**
* Popup launched from wysiwyg to embed an image
* @return void
*/
public function action_embed()
{
$id = $this->request->param('id', 0);
$sizes = $this->_settings->get('sizes_embed');
if ($id > 0) {
// get size from qs
$size = $this->param('param1');
} else {
// get first size
$size = $sizes[0];
}
// create form
$form = Form::factory($this->_settings->get('form_embed'));
// set urls
$form->urls(array('submit' => URL::to($this->request->controller() . '@embed:' . $id, array('query' => 'after=embed')), 'submit_back' => URL::to($this->request->controller() . '@embed:' . $id, array('query' => 'after=close')), 'back' => URL::to($this->request->controller() . '@close')));
// set vars in from
$form->controller($this->request->controller());
$form->sizes($sizes);
// populate form
$form->value('id', $id);
$form->value('size', $size);
// proces form
if ($form->valid()) {
$data = $form->values();
// get the image model
$model = ORM::factory($this->_settings->get('model'), $data['id']);
// get actual base url for the current website
$base_url = Website::instance()->base_url($this->_website, Kohana::$base_url) . $this->_settings->get('url_images');
// get the source
$data['src'] = $model->src($data['size'], $base_url);
// check if it can be enlarged
$data['enlarge'] = $model->size($this->_settings->get('size_enlarge')) === FALSE ? '0' : '1';
// get callback
$callback = $this->request->param('callback', '');
// render close dialog
$view = View::factory($this->_settings->get('view.close'), array('data' => $data, 'callback' => $callback));
$this->response->body($view->render());
} else {
// create view
$viewer = Viewer::factory('Form', $form)->text(Text::instance());
$view = View::factory($this->_settings->get('view.update'), array('viewer' => $viewer));
$this->response->body($view->render());
}
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:48,代码来源:Image.php
示例7: array
*/
Route::set('access', 'access/<token>(/<controller>(/<action>(/<id>(/<param1>))))')->defaults(array('token' => '', 'controller' => 'Home', 'action' => 'index'));
/**
* INTERNAL SUBREQUEST
*/
Route::set('internal', 'internal_<controller>(@<action>(:<id>))', array('controller' => '[a-zA-Z0-9\\_\\-]+', 'action' => '[a-zA-Z0-9\\_\\-]+'))->defaults(array('action' => 'index'));
/**
* LOCAL ALIAS NEWS
*/
Route::set('news', '(website_<website>/)actueel/<id>', array('website' => $websites_pattern))->defaults(array('controller' => 'News', 'action' => 'view'));
/**
* LOCAL ALIAS EVENT
*/
Route::set('event', '(website_<website>/)agenda/<id>', array('website' => $websites_pattern))->defaults(array('controller' => 'Event', 'action' => 'view'));
/**
* ALIAS
*/
// cache aliases
Alias::cache(Cache::instance('alias'));
Route::set('alias', '(website_<website>(/))(<uri>)', array('website' => $websites_pattern, 'uri' => '[a-zA-Z0-9\\-]+'))->filter(function ($route, $params, $request) {
if (isset($params['uri']) && $params['uri'] != '') {
$aliasParams = Alias::factory()->params($params['uri'], Website::instance()->uri($request->uri())->id());
return $aliasParams ? $aliasParams : FALSE;
} else {
return FALSE;
}
});
/**
* FRONTEND
*/
Route::set('frontend', '(website_<website>(/))(<controller>(/<action>(/<id>(/<param1>(/<param2>(/<param3>))))))(?<query>)', array('website' => $websites_pattern))->defaults(array('controller' => 'Page', 'action' => 'view'));
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:31,代码来源:routes.php
示例8: Date
View::block('class_body', '');
?>
">
<!-- Google Analytics -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<?php
echo $_config->ga;
?>
', '<?php
echo Website::instance()->domain();
?>
');
ga('send', 'pageview');
</script>
<nav class="yf-nav">
<div class="yf-container container">
<!-- Top Menu -->
<div class="nav-top hidden-small">
<?php
echo $_menu_top;
?>
</div>
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:31,代码来源:_base.php