本文整理汇总了PHP中Lang::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::load方法的具体用法?PHP Lang::load怎么用?PHP Lang::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lang
的用法示例。
在下文中一共展示了Lang::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public static function run($uri)
{
self::$router = new Router($uri);
self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . "Controller";
$controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
$layout = self::$router->getRoute();
if ($layout == "admin" && Session::get("role") != "admin") {
if ($controller_method != "admin_login") {
Router::redirect("/admin/users/login");
}
}
//Calling controller's method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception("Method {$controller_method} does not exist in {$controller_class}");
}
$layout_path = VIEWS_PATH . DS . $layout . ".html";
$layout_view_object = new View(compact('content'), $layout_path);
echo $layout_view_object->render();
}
示例2: run
public static function run($uri)
{
self::$router = new Router($uri);
# создаем обект базы данных и передаем параметры подключения
self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . 'Controller';
$controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
# при каждом запросе к руту admin выполняется проверка, имеет ли пользователь на это права
$layout = self::$router->getRoute();
if ($layout == 'admin' && Session::get('role') != 'admin') {
if ($controller_method != 'admin_login') {
Router::redirect('/admin/users/login');
}
}
// Calling controller's method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
}
# код віполняющий рендеринг
$layout_path = VIEWS_PATH . DS . $layout . '.html';
$layout_view_object = new View(compact('content'), $layout_path);
echo $layout_view_object->render();
}
示例3: displayForm
/** @inheritdoc */
public static function displayForm($value, &$settings, $model)
{
// No point in ever showing this field if lang isn't enabled
if (!\CMF::$lang_enabled) {
return '';
}
\Lang::load('languages', true, 'en', true, true);
$settings = static::settings($settings);
$include_label = isset($settings['label']) ? $settings['label'] : true;
$required = isset($settings['required']) ? $settings['required'] : false;
$errors = $model->getErrorsForField($settings['mapping']['fieldName']);
$has_errors = count($errors) > 0;
$input_attributes = isset($settings['input_attributes']) ? $settings['input_attributes'] : array('class' => 'input-xxlarge');
if ($settings['active_only']) {
$options = array_map(function ($lang) {
return \Arr::get(\Lang::$lines, 'en.languages.' . $lang['code'], \Lang::get('admin.errors.language.name_not_found'));
}, \CMF\Model\Language::select('item.code', 'item', 'item.code')->orderBy('item.pos', 'ASC')->where('item.visible = true')->getQuery()->getArrayResult());
} else {
$options = \Arr::get(\Lang::$lines, 'en.languages', array());
}
// Whether to allow an empty option
if (isset($settings['mapping']['nullable']) && $settings['mapping']['nullable'] && !$required && $settings['allow_empty']) {
$options = array('' => '') + $options;
}
$label = !$include_label ? '' : \Form::label($settings['title'] . ($required ? ' *' : '') . ($has_errors ? ' - ' . $errors[0] : ''), $settings['mapping']['fieldName'], array('class' => 'item-label'));
$input = \Form::select($settings['mapping']['fieldName'], $value, $options, $input_attributes);
if (isset($settings['wrap']) && $settings['wrap'] === false) {
return $label . $input;
}
return html_tag('div', array('class' => 'controls control-group' . ($has_errors ? ' error' : '')), $label . $input);
}
示例4: __construct
/**
* Cart constructor
*
* @param void
* @return void
*/
public function __construct()
{
// Initialize DB
$this->_db = App::get('db');
// Load language file
Lang::load('com_cart');
}
示例5: run
public static function run($uri)
{
self::$router = new Router($uri);
self::$db = new DB(config::get('db.host'), config::get('db.name'), config::get('db.user'), config::get('db.password'));
Lang::load(self::$router->getLanguage());
if ($_POST and (isset($_POST['username_in']) and isset($_POST['password_in'])) or isset($_POST['exit'])) {
$us = new RegisterController();
if (isset($_POST['exit'])) {
$us->LogOut();
} else {
$us->Login($_POST);
}
}
if (self::$router->getController() == 'admin' and !Session::getSession('root') or self::$router->getController() == 'myblog' and !Session::getSession('id')) {
self::$router->setController(Config::get('default_controller'));
self::$router->setAction(Config::get('default_action'));
Session::setSession('message', 'Отказ в доступе');
}
$controller_class = ucfirst(self::$router->getController()) . 'Controller';
$controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$controller_object->{$controller_method}();
$view_object = new View($controller_object->getData());
$content = $view_object->render();
} else {
throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist');
}
$layout = self::$router->getRoute();
$layout_path = VIEWS_PATH . DS . $layout . '.html';
$layout_view_object = new View(compact('content'), $layout_path);
echo $layout_view_object->render();
}
示例6: sendMailByParams
/**
* ユーザーにメールを送信
*
* @para $name メールの識別子 $params 差し込むデータ $to 送り先(指定しなければ langの値を使用) $options Fuel準拠のEmailオプション
* @access protected
* @return bool
* @author kobayasi
* @author shimma
*/
public function sendMailByParams($name, $params = array(), $to = null, $options = null)
{
Lang::load("email/{$name}");
$email = Email::forge();
$email->from(Lang::get('from'), Lang::get('from_name'));
$email->subject($this->renderTemplate(Lang::get('subject'), $params, false));
$email->body($this->renderTemplate(Lang::get('body'), $params));
if (!$to) {
$to = Lang::get('email');
}
$email->to($to);
if (Lang::get('bcc') != '') {
$email->bcc(Lang::get('bcc'));
}
if (!empty($options)) {
foreach ($options as $option => $value) {
if (empty($value)) {
continue;
}
switch ($option) {
case 'bcc':
$email->bcc($value);
break;
case 'reply_to':
$email->reply_to($value);
break;
case 'subject':
$email->subject($value);
break;
}
}
}
return $email->send();
}
示例7: IndexbaseModule
function IndexbaseModule()
{
define_module();
Lang::load(module_lang('common'));
$this->visitor =& env('visitor');
parent::__construct();
}
示例8: run
public static function run($uri)
{
self::$router = new Router($uri);
self::$db = DB::getInstance(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
Lang::load(self::$router->getLanguage());
$controller_class = ucfirst(self::$router->getController()) . 'controller';
$controller_method = strtolower(self::$router->getMethod_prefix() . self::$router->getAction());
$controller_parametr = self::$router->getParams();
$layout = self::$router->getRoute();
if ($layout == 'admin' && Session::get('role') != 'admin') {
if ($controller_method != 'admin_login') {
Router::redirect('/admin/users/login');
}
}
//Calling conrollers method
$controller_object = new $controller_class();
if (method_exists($controller_object, $controller_method)) {
$view_path = $controller_object->{$controller_method}();
$view_object = new View($controller_object->getData(), $view_path);
$content = $view_object->render();
} else {
throw new Exception('Метод ' . $controller_method . ' в классе ' . $controller_class . 'не найден');
}
$layout_path = VIEW_PATH . DS . $layout . '.html';
$layout_view_object = new View(compact('content'), $layout_path);
// основной рендер вывода страниц
echo $layout_view_object->render();
}
示例9: _init
public static function _init()
{
\Lang::load('menu');
\Config::load('petro', true);
static::$table = \Config::get('petro.menu.table', 'menu');
static::$template = \Config::get('petro.template.menu');
}
示例10: test_line_invalid
/**
* Test for Lang::get()
*
* @test
*/
public function test_line_invalid()
{
Lang::load('test');
$output = Lang::get('non_existant_hello', array('name' => 'Bob'));
$expected = false;
$this->assertEquals($expected, $output);
}
示例11: before
/**
* Run this code before the other methods.
*/
public function before()
{
// Load the error strings.
\Lang::load('v1::errors', true);
\Lang::load('v1::log', true);
\Lang::load('v1::response', true);
}
示例12: before
/**
* Run this before every call
*
* @return void
* @access public
*/
public function before()
{
// Profile the loader
\Profiler::mark('Start of loader\'s before() function');
\Profiler::mark_memory($this, 'Start of loader\'s before() function');
// Set the environment
parent::before();
// Load the config for Segment so we can process analytics data.
\Config::load('segment', true);
// Load the config file for event names. Having events names in one place keeps things synchronized.
\Config::load('analyticsstrings', true);
// Engine configuration
\Config::load('engine', true);
// Load the package configuration file.
\Config::load('tiers', true);
// Soccket connection configuration
\Config::load('socket', true);
/**
* Ensure that all user language strings are appropriately translated.
*
* @link https://github.com/fuel/core/issues/1860#issuecomment-92022320
*/
if (is_string(\Input::post('language', false))) {
\Environment::set_language(\Input::post('language', 'en'));
}
// Load the error strings.
\Lang::load('errors', true);
}
示例13: _init
public static function _init()
{
\Config::load('petro', true);
\Lang::load('petro');
static::$template = \Config::get('petro.template');
static::$csrf_token_key = \Config::get('security.csrf_token_key', 'fuel_csrf_token');
}
示例14: action_index
public function action_index()
{
// clear redirect referrer
\Session::delete('submitted_redirect');
// load language
\Lang::load('index');
// read flash message for display errors.
$form_status = \Session::get_flash('form_status');
if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
$output['form_status'] = $form_status['form_status'];
$output['form_status_message'] = $form_status['form_status_message'];
}
unset($form_status);
// get total accounts
$output['total_accounts'] = \Model_Accounts::count();
// <head> output ----------------------------------------------------------------------------------------------
$output['page_title'] = $this->generateTitle(\Lang::get('admin_administrator_dashbord'));
// <head> output ----------------------------------------------------------------------------------------------
// breadcrumb -------------------------------------------------------------------------------------------------
$page_breadcrumb = [];
$page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
$output['page_breadcrumb'] = $page_breadcrumb;
unset($page_breadcrumb);
// breadcrumb -------------------------------------------------------------------------------------------------
// the admin views or theme should follow this structure. (admin/templates/controller/method) and follow with _v in the end.
return $this->generatePage('admin/templates/index/index_v', $output, false);
}
示例15: emailMemberDigest
/**
* Email member activity digest
*
* Current limitations include a lack of queuing/scheduling. This means that this cron job
* should not be set to run more than once daily, otherwise it will continue to send out the
* same digest to people over and over again.
*
* @param object $job \Components\Cron\Models\Job
* @return bool
*/
public function emailMemberDigest(\Components\Cron\Models\Job $job)
{
// Make sure digests are enabled? The cron job being on may be evidence enough...
if (!Plugin::params('members', 'activity')->get('email_digests', false)) {
return true;
}
// Load language files
Lang::load('plg_members_activity') || Lang::load('plg_members_activity', PATH_CORE . DS . 'plugins' . DS . 'members' . DS . 'activity');
// Database connection
$db = App::get('db');
// 0 = no email
// 1 = immediately
// 2 = digest daily
// 3 = digest weekly
// 4 = digest monthly
$intervals = array(0 => 'none', 1 => 'now', 2 => 'day', 3 => 'week', 4 => 'month');
// Check frequency (this plugin should run early every morning)
// If daily, run every day
// If weekly, only run this one on mondays
// If monthly, only run this on on the 1st of the month
$isDay = true;
$isWeek = Date::of('now')->toLocal('N') == 1 ? true : false;
$isMonth = Date::of('now')->toLocal('j') == 1 ? true : false;
foreach ($intervals as $val => $interval) {
// Skip the first two options for now
if ($val < 2) {
continue;
}
if ($val == 3 && !$isWeek) {
continue;
}
if ($val == 4 && !$isMonth) {
continue;
}
// Find all users that want weekly digests and the last time the digest
// was sent was NEVER or older than 1 month ago.
$previous = Date::of('now')->subtract('1 ' . $interval)->toSql();
// Set up the query
$query = "SELECT DISTINCT(scope_id) FROM `#__activity_digests` WHERE `scope`=" . $db->quote('user') . " AND `frequency`=" . $db->quote($val) . " AND (`sent` = '0000-00-00 00:00:00' OR `sent` <= " . $db->quote($previous) . ")";
$db->setQuery($query);
$users = $db->loadColumn();
// Loop through members and get their groups that have the digest set
if ($users && count($users) > 0) {
foreach ($users as $user) {
$posts = \Hubzero\Activity\Recipient::all()->including('log')->whereEquals('scope', 'user')->whereEquals('scope_id', $user)->whereEquals('state', 1)->where('created', '>', $previous)->ordered()->rows();
// Gather up applicable posts and queue up the emails
if (count($posts) > 0) {
if ($this->sendEmail($user, $posts, $interval)) {
// Update the last sent timestamp
$query = "UPDATE `#__activity_digests` SET `sent`=" . $db->quote(Date::toSql()) . " WHERE `scope`=" . $db->quote('user') . " AND `scope_id`=" . $db->quote($user);
$db->setQuery($query);
$db->query();
}
}
}
}
}
return true;
}