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(); }
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(); }
/** @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); }
/** * Cart constructor * * @param void * @return void */ public function __construct() { // Initialize DB $this->_db = App::get('db'); // Load language file Lang::load('com_cart'); }
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(); }
/** * ユーザーにメールを送信 * * @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(); }
function IndexbaseModule() { define_module(); Lang::load(module_lang('common')); $this->visitor =& env('visitor'); parent::__construct(); }
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(); }
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'); }
/** * 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); }
/** * 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); }
/** * 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); }
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'); }
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); }
/** * 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; }
/** * Contructor * * @param void * @return void */ public function __construct($code = false) { // Load language file Lang::load('com_storefront'); if ($code) { $this->setCode($code); } }
/** * 拾いきれてないエラー * * @access public * @return void * @author ida */ public function action_error() { $error_code = \Model_Error::ER00000; $error_list = Lang::load('error/user', $error_code); $error_message = $error_list[$error_code]; $this->template->title = $error_code; $this->template->content = \View::forge('errors/index', array('error_code' => $error_code, 'error_message' => $error_message)); }
/** * Initial render view * * @return string */ public static function render() { // Load language Lang::load('plg_time_weeklybar', __DIR__); // Create view $view = new \Hubzero\Plugin\View(array('folder' => 'time', 'element' => 'weeklybar', 'name' => 'overview')); return $view->loadTemplate(); }
public function before() { parent::before(); $this->_auth = Auth::instance(); $userids = $this->_auth->get_user_id(); $this->_user_id = $userids[1]; //loads messages for event controller Lang::load("event"); }
function IntegraterApp() { parent::__construct(); Lang::load(version_data('common.lang.php')); if (file_exists(LOCK_FILE)) { $this->show_message('integrate_locked'); return; } }
/** * Country helper function. * * @return string */ public function country() { if (empty($this->country)) { return false; } Lang::load('countries', true); $countries = __('countries'); return $countries[$this->country]; }
public static function _init() { \Lang::load('petro'); \Config::load('petro', true); static::$ignore_login = array_merge(\Config::get('petro.auth.ignore'), \Config::get('petro.auth.url')); static::set_title(\Config::get('petro.site_name', '')); $load_from_table = \Config::get('petro.menu.load_from_table', false); static::set_menu($load_from_table ? Petro_Menu::load_from_table() : \Config::load('petro_menu')); }
public function action_404() { Lang::load('error', 'error'); $output['error_head'] = Lang::get('error.404_error_head'); $output['error_content'] = Lang::get('error.404_error_content', array('home_link' => Uri::base())); // <head> output ---------------------------------------------------------------------------------------------- $output['page_title'] = Lang::get('error.404_page_title'); // <head> output ---------------------------------------------------------------------------------------------- return Response::forge(Theme::instance()->view('error/404_v', $output)->auto_filter(false), 404); }
/** * class initialisation, load the config and process $_FILES if needed * * @return void */ public static function _init() { // get the config for this upload \Config::load('upload', true); // get the language file for this upload \Lang::load('upload', true); // make sure we have defaults for those not defined static::$config = array_merge(static::$_defaults, \Config::get('upload', array())); static::$config['auto_process'] and static::process(); }
function OauthModule() { parent::__construct(); Lang::load(lang_file('member')); $model_module =& m('module'); $find_data = $model_module->find('index:' . MODULE); $info = current($find_data); $this->_configs = unserialize($info['module_config']); $this->_configs['qq']['callback'] = SITE_URL . "/index.php?module=oauth&act=qqcallback"; }
function InstallerApp() { $this->_define_lang(); Lang::load(version_data('common.lang.php')); if (file_exists(LOCK_FILE)) { header('Content-Type:text/html;charset=' . CHARSET); die(Lang::get('install_locked')); } parent::__construct(); }
public function __construct() { parent::__construct(); // validate admin logged in if (\Model_Accounts::isAdminLogin() == false) { \Response::redirect(\Uri::create('admin/login') . '?rdr=' . urlencode(\Uri::main())); } // load global admin language \Lang::load('admin'); }
public function before() { parent::before(); // Check permission $this->check_permission(); //Load language Config::set('language', 'vi'); Lang::load('language_admin.ini'); $this->init_css(); $this->init_js(); }
function FrontendApp() { Lang::load(lang_file('common')); Lang::load(lang_file(APP)); parent::__construct(); // 判断商城是否关闭 if (!Conf::get('site_status')) { $this->show_warning(Conf::get('closed_reason')); exit; } # 在运行action之前,无法访问到visitor对象 }
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 == 'user' && Session::get('role') != 'user') { if ($controller_method != 'login') { Router::redirect('/users/login'); } } elseif ($layout == 'admin' && Session::get('role') != 'admin') { if ($controller_method != 'admin_login') { Router::redirect('/admin/users/login'); } } $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(); }