当前位置: 首页>>代码示例>>PHP>>正文


PHP Text::instance方法代码示例

本文整理汇总了PHP中Text::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Text::instance方法的具体用法?PHP Text::instance怎么用?PHP Text::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Text的用法示例。


在下文中一共展示了Text::instance方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 public function before()
 {
     // set default route
     URL::route('frontend');
     Text::language('nl');
     Text::instance('nl')->load($this->request->controller())->group($this->request->controller())->substitutes('module');
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:7,代码来源:Base.php

示例2: handle_menu_after_form

 /**
  * add modules and requets from settings
  * @param type $data
  */
 public function handle_menu_after_form($data)
 {
     $text = Text::instance();
     $modules = array();
     foreach ($this->_settings->get('modules') as $module) {
         $modules[$module] = $text->get($module . ':module.name');
     }
     $requests = array();
     foreach ($this->_settings->get('requests') as $request) {
         $requests[$request] = $text->get('option.request.' . $request);
     }
     $data->form->modules($modules);
     $data->form->requests($requests);
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:18,代码来源:Menu.php

示例3: action_update

 /**
  * update
  */
 public function action_update()
 {
     // get model
     $model = ORM::factory($this->_settings->get('model'))->filter('website_id', $this->_website)->find();
     // create form
     $form = Form::factory($this->_settings->get('form'));
     // add request to form
     $form->request($this->request);
     // add text to form
     $form->text(Text::instance());
     // add model to form
     $form->model($model);
     // add urls
     $form->urls(array('submit' => URL::to($this->request->controller() . '@update'), 'back' => URL::to($this->request->controller())));
     // do the action
     if ($this->update($model, $form)) {
         //redirect
         $this->redirect_done('updated');
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:23,代码来源:Single.php

示例4: action_roles

 /**
  * add or remove roles from user
  */
 public function action_roles()
 {
     $id = $this->param('id');
     $user = ORM::factory($this->_settings->get('model'), $id);
     $acl = Acl::instance();
     $form = Form::factory('Roles');
     $form->urls(array('submit' => URL::to($this->request->controller() . '@roles:' . $id, array('query' => 'after=roles')), 'submit_back' => URL::to($this->request->controller() . '@roles:' . $id), 'back' => URL::to($this->request->controller())));
     // get roles
     $roles = $acl->roles();
     sort($roles);
     $options = array();
     $text = Text::instance();
     foreach ($roles as $role) {
         $parts = explode('_', $role);
         if ($parts[0] === 'manager') {
             $label = $text->get('option.roles.manager') . ' ' . $parts[1];
         } else {
             $label = $text->get('option.roles.' . $role);
         }
         $options[$role] = $label;
     }
     // set all the available roles
     $form->roles($options);
     // set roles in form
     $form->value('roles', $user->roles);
     if ($form->valid()) {
         // filter out illegal attempts to upgrade roles
         $roles = array_intersect($form->value('roles'), $acl->roles());
         // set & save roles
         $user->roles = $roles;
         $user->save();
         $this->redirect_done('updated');
     }
     // create viewer
     $viewer = Viewer::factory('Form', $form)->text(Text::instance());
     // create view
     $view = View::factory($this->_settings->get('view.update'), array('viewer' => $viewer));
     // response
     $this->response->body($view->render());
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:43,代码来源:User.php

示例5: 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

示例6: update

 /**
  * update items
  *
  * @param int $id
  * @param array $addit_values
  * @param array $form_data
  * @return boolean
  */
 protected function update($model, $form)
 {
     if (!Acl::instance()->allowed($this->_controller, 'update', $model->owner_id, $model->website_id)) {
         throw HTTP_Exception::factory(403, 'Update not allowed on :controller :id', array(':controller' => $this->_controller, ':id' => $model->id));
     }
     if (isset($model->updatable) && $model->updatable == 0) {
         throw HTTP_Exception::factory(403, 'Update not allowed on :controller :id', array(':controller' => $this->_controller, ':id' => $model->id));
     }
     //populate fields from db
     $form->values($model->as_map());
     // call hook
     Event::raise($this, Event::BEFORE_UPDATE_FORM_PARSE, array('model' => $model, 'form' => $form));
     // check if valid
     if ($form->valid()) {
         Event::raise($this, Event::BEFORE_UPDATE_VALUES, array('model' => $model, 'form' => $form));
         // set values
         $model->values($form->values());
         // set editor id
         $model->editor_id = Identity::instance()->id;
         // call hook
         Event::raise($this, Event::BEFORE_UPDATE, array('model' => $model, 'form' => $form));
         //save
         $model->save();
         // call hook
         Event::raise($this, Event::AFTER_UPDATE, array('model' => $model, 'form' => $form));
         // done
         return TRUE;
     } else {
         // set message if form was submitted (there's an error)
         if ($form->submitted() === TRUE) {
             $this->error_message('invalid');
         }
         // create viewer
         $viewer = Viewer::factory('Form', $form)->text(Text::instance());
         // create view
         $view = View::factory($this->_settings->get('view.update'), array('viewer' => $viewer));
         // raise event
         Event::raise($this, Event::BEFORE_UPDATE_RENDER, array('model' => $model, 'form' => $form, 'viewer' => $viewer, 'view' => $view));
         // response
         $this->response->body($view->render());
         // not done
         return FALSE;
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:52,代码来源:Item.php

示例7: text

/**
* Helper function for Views
* Create an instance with the default language and call get
*/
function text($path, $substitutes = array(), $ucFirst = true)
{
    return Text::instance()->get($path, $substitutes, $ucFirst);
}
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:8,代码来源:Text.php

示例8: 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

示例9: redirect_done

 /**
  * redirect to list
  *
  * @param string $messageId
  * @param array $params 
  */
 protected function redirect_done($messageId = FALSE, $params = array())
 {
     // leave a message
     if ($messageId) {
         $message = array('status' => 'success', 'message' => Text::instance()->get('message.' . $messageId));
         Session::instance('database')->set('message', $message);
     }
     // default controller
     if (!isset($params['website'])) {
         $params['website'] = $this->_website;
     }
     // default controller
     if (!isset($params['controller'])) {
         $params['controller'] = $this->_controller;
     }
     // default action
     if (!isset($params['action'])) {
         $params['action'] = 'index';
     }
     // redirect
     $this->redirect(URL::to($params));
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:28,代码来源:Module.php

示例10: action_login

 /**
  * do login
  *
  * @param string $username
  * @param string $password
  */
 public function action_login()
 {
     // create text
     $text = Text::instance();
     // create form
     $form = Form::factory('Login');
     $form->urls(array('submit' => URL::to('Auth@login')));
     // check form
     $authenticated = false;
     $message = false;
     if ($form->valid()) {
         // get the values
         $values = $form->values();
         // create identity
         $identity = Identity::instance();
         // check if these are valid credentials
         $authenticated = $identity->authenticate($values['username'], $values['password']);
         // add error if not authenticated
         if ($authenticated) {
             // check if user is blocked
             if ($identity->user && $identity->user->status == Model_User::STATUS_ACTIVE) {
             } else {
                 $identity->destroy();
                 $authenticated = false;
                 $message = $text->get('error.blocked');
             }
         } else {
             $message = $text->get('error.credentials');
         }
     }
     if ($authenticated) {
         // if ok, set flash message and redirect to default page
         // set message
         $message = array('status' => 'success', 'message' => $text->get('message.success'));
         Session::instance('database')->set('message', $message);
         //redirect
         $url = URL::to('Default@redirect_website');
         $this->redirect($url);
     } else {
         // else show form
         $body = View::factory('login', array('viewer' => Viewer::factory('Form', $form)->text(Text::instance()), 'message' => $message, 'text' => $text))->render();
         $this->response->body($body);
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:50,代码来源:Auth.php

示例11: switch

<?php

/**
 * @package		CleverStyle CMS
 * @subpackage	System module
 * @category	modules
 * @author		Nazar Mokrynskyi <nazar@mokrynskyi.com>
 * @copyright	Copyright (c) 2011-2014, Nazar Mokrynskyi
 * @license		MIT License, see license.txt
 */
namespace cs;

$Cache = Cache::instance();
$Config = Config::instance();
$L = Language::instance();
$Text = Text::instance();
$Permission = Permission::instance();
$a = Index::instance();
if (isset($_POST['mode'])) {
    switch ($_POST['mode']) {
        case 'add':
        case 'edit':
            $block_new =& $_POST['block'];
            if ($_POST['mode'] == 'add') {
                $block = ['position' => 'floating', 'type' => xap($block_new['type']), 'index' => substr(TIME, 3)];
            } else {
                $block =& $Config->components['blocks'][$block_new['id']];
            }
            $block['title'] = $Text->set($Config->module('System')->db('texts'), 'System/Config/blocks/title', $block['index'], $block_new['title']);
            $block['active'] = $block_new['active'];
            $block['template'] = $block_new['template'];
开发者ID:hypnomez,项目名称:opir.org,代码行数:31,代码来源:save.blocks.php

示例12: store

 /**
  * create files in db
  */
 protected function store($form, $hash)
 {
     // get files in the temp/hash dir
     $files = FS::files($this->_settings->get('path_temp') . $hash . DIRECTORY_SEPARATOR);
     // set the files in the form
     $form->files($files);
     Event::raise($this, Event::BEFORE_STORE_FORM_PARSE, array('form' => $form));
     if ($form->valid()) {
         // get the hash of the temp dir from qs
         $hash = $this->request->param('id');
         // get the form values
         $values = $form->values();
         // loop through temp files
         for ($i = 0; $i < count($files); $i++) {
             // createmodel
             $model = ORM::factory($this->_settings->get('model'));
             // set group if one is active
             if ($group = $this->_state->get('group', FALSE)) {
                 $model->group_id = $group;
             }
             // undouble filename
             $file = FS::name_unique($files[$i], $this->_settings->get('path_files'));
             // store it
             FS::move($this->_settings->get('path_temp') . $hash . DIRECTORY_SEPARATOR . $files[$i], $this->_settings->get('path_files') . $file);
             // permissions
             FS::permissions($this->_settings->get('path_files') . $file, 0744);
             // set item properties
             $model->created = date('y-m-d H:i:s', time());
             $model->owner_id = Identity::instance()->id;
             $model->editor_id = Identity::instance()->id;
             $model->website_id = $this->_website;
             // set file
             $model->file = $file;
             // set additional info (mostly title)
             foreach ($values as $key => $value) {
                 if (is_array($value) && isset($value[$i])) {
                     $model->{$key} = $value[$i];
                 }
             }
             // call hook
             Event::raise($this, Event::BEFORE_STORE, array('model' => $model, 'form' => $form));
             //save
             $model->save();
             // call hook
             Event::raise($this, Event::AFTER_STORE, array('model' => $model, 'form' => $form));
         }
         // return true
         return TRUE;
     } else {
         // create viewer
         $viewer = Viewer::factory('Form', $form)->text(Text::instance());
         // render form
         $view = View::factory($this->_settings->get('view.create'), array('viewer' => $viewer));
         // event
         Event::raise($this, Event::BEFORE_STORE_RENDER, array('model' => NULL, 'form' => $form, 'viewer' => $viewer, 'view' => $view));
         // render
         $this->response->body($view->render());
         // return false
         return FALSE;
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:64,代码来源:File.php

示例13: filter_settings

 /**
  * Get possible filters
  * @return type
  */
 public function filter_settings()
 {
     $settings = array('filters' => array());
     $text = Text::instance();
     $filters = array();
     foreach ($this->_settings['filter'] as $field => $setting) {
         $filter = array('value' => $field, 'label' => $text->get('label.' . $field), 'type' => $setting['type'], 'operators' => array(), 'options' => array());
         foreach ($setting['operators'] as $operator) {
             $filter['operators'][$operator] = array('value' => $operator, 'label' => $text->get('option.operator.' . $operator));
         }
         if ($setting['type'] === 'option') {
             foreach ($setting['options'] as $option) {
                 $filter['options'][$option] = array('value' => $option, 'label' => $text->get('option.' . $field . '.' . $option));
             }
         }
         if ($setting['type'] === 'relation') {
             $model = ORM::factory($setting['model']);
             $options = $model->find_all()->as_array();
             foreach ($options as $option) {
                 $filter['options'][$option->id] = array('value' => $option->id, 'label' => $option->{$setting['field']});
             }
         }
         $filters[$field] = $filter;
     }
     return $filters;
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:30,代码来源:List.php


注:本文中的Text::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。