예제 #1
0
 public function getLanguage()
 {
     if (!$this->language instanceof Language && is_numeric($this->language)) {
         $this->language = DBFactory::get('languages')->get($this->language);
     }
     return $this->language;
 }
예제 #2
0
 public function getAdmin()
 {
     if (is_null($this->admin)) {
         $this->admin = DBFactory::get('admins')->get($this->getSessionParam('admin'));
     }
     return $this->admin;
 }
예제 #3
0
 public function updateAction()
 {
     if (empty($_GET['id']) || !($language = DBFactory::get($this->module)->get($_GET['id'])) instanceof Language) {
         Header::location(UrlFactory::module($this->module));
     }
     $this->valid($language, $_POST);
     $view = $this->getView('Form');
     $view->language = $language;
     $layout = $this->getLayout('Default', $view);
     $layout->addBreadcrumbsLink(new Link(Translator::get('module_languages'), UrlFactory::module($this->module)));
     $layout->addBreadcrumbsLink(new Link($language->name, UrlFactory::update($this->module, $language)));
     $layout->addBreadcrumbsLink(new Link(Translator::get('module_update')));
 }
예제 #4
0
 public function loginAction()
 {
     if (!empty($_POST)) {
         unset($_SESSION['admin']);
         $admin = DBFactory::get($this->module)->getForConnection($_POST);
         if ($admin instanceof Admin) {
             $_SESSION['admin'] = $admin->id;
             $_SESSION['last_connection'] = $admin->last_connection;
             DBFactory::get($this->module)->updateLastConnection($admin);
             $this->response->location = UrlFactory::module('home');
         }
     }
     require_once MODEL . 'Admin.php';
     $admin = new Admin();
     $view = $this->getView('Login');
     $view->admin = $admin;
     $layout = $this->getLayout('Default', $view);
     $layout->navigation = false;
     $layout->breadcrumbs = false;
     $layout->sidebar = false;
     $layout->addBodyClass('login');
 }
예제 #5
0
 public function delete()
 {
     return DBFactory::get('translations')->delete($this);
 }
예제 #6
0
파일: index.php 프로젝트: ben33/framework
                }
            }
        }
    }
}
$request->langue = $response->langue = $userLangue;
define('LANGUE', $request->langue->code);
define('BASE_URL_LANGUE', BASE_URL . $request->langue->code . '/');
ini_set('default_charset', CHARSET);
setlocale(LC_TIME, $request->langue->locale . '.' . mb_strtolower(CHARSET));
if (in_array('translations', $backoModules) && file_exists(ROOT . 'traductions.inc.php')) {
    Translator::init($request->langue->code, DEFAULT_LANG);
}
require_once APPLICATION_ROOT . 'UrlFactory.php';
UrlSingleton::init(new UrlFactory(), $request->langue);
if (in_array('admins', $allowedModules) && (empty($_SESSION['admin']) || !($admin = DBFactory::get('admins')->get($_SESSION['admin'])) instanceof Admin) && $request->url != UrlFactory::module('admins', 'login') && $request->url != UrlFactory::module('admins', 'init')) {
    Header::location(UrlFactory::module('admins', 'login'));
}
try {
    if (!file_exists($file = APPLICATION_MODULES . $request->module . DS . $request->controller . '.php')) {
        throw new Error404Exception($response);
    }
    require $file;
    $controller = new $request->controller($response);
    Logger::addPhpLog($request);
    if (!method_exists($controller, $request->method)) {
        throw new Error404Exception($response);
    }
    $controller->handleRequest($request);
} catch (Error404Exception $exception) {
    require APPLICATION_MODULES . 'errors' . DS . 'ErrorsController.php';
예제 #7
0
 public function delete()
 {
     return DBFactory::get('languages')->delete($this);
 }
예제 #8
0
 private function generate()
 {
     $translations = DBFactory::get($this->module)->getAll();
     $tab = array();
     $export = array();
     $languages = DBFactory::get('languages')->getEnabled();
     $content = '<?php' . "\n";
     if (!empty($translations)) {
         foreach ($translations as $translation) {
             foreach ($languages as $language) {
                 if ($language->code == DEFAULT_LANG || !empty($traduction->get($langue))) {
                     $export[$language->code][$translation->variable] = $translation->get($language);
                 }
             }
         }
         ob_start();
         var_export($export);
         $tab = ob_get_contents();
         ob_end_clean();
     }
     $content .= '$traductions = ' . $tab . ';';
     file_put_contents(ROOT . 'traductions.inc.php', $content);
 }