Exemplo n.º 1
0
 /**
  * @depends testLoadLang
  */
 public function testLoadLError()
 {
     //Clean cache loaded
     global $base_path;
     I18n::$base_path = $base_path;
     I18n::$arr_i18n = ['en-US'];
     I18n::$language = 'en-US';
     I18n::$cache_lang = array();
     $this->assertFalse(I18n::load_lang('common_not_exists'));
 }
Exemplo n.º 2
0
use PhangoApp\PhaI18n\I18n;
Routes::$base_path = __DIR__;
chdir(Routes::$base_path);
Utils::load_config('config_routes');
Utils::load_config('config_i18n');
Utils::load_config('config');
Utils::load_config('config_views');
/**Load configurations from modules**/
foreach (Routes::$apps as $admin_module) {
    Utils::load_config('config', $path = 'vendor/' . $admin_module . "/settings");
}
/*
include('libraries/fields/corefields.php');
include('libraries/forms/coreforms.php');
*/
I18n::load_lang('common');
//Load extra libraries
/*Utils::load_libraries(array('fields/corefields'));
Utils::load_libraries(array('forms/coreforms'));*/
//date_default_timezone_set (MY_TIMEZONE);
$utility_console = 1;
//load_lang('common', 'user');
$model = array();
//Check arguments
define('OPTS', 'm:c:');
$longopts = array();
$options = getopt(OPTS, $longopts);
$climate = new League\CLImate\CLImate();
if (!isset($options['m']) && !isset($options['c'])) {
    //die("Use: php console.php -m=module -c=console_controller [more arguments for daemon]\n");
    $climate->white()->backgroundBlack()->out("Use: php console.php -m=group/module -c=console_controller [more arguments for daemon]");
Exemplo n.º 3
0
<?php

use PhangoApp\PhaModels\Webmodel;
use PhangoApp\PhaI18n\I18n;
use PhangoApp\PhaLibs\GenerateAdminClass;
use PhangoApp\PhaLibs\AdminUtils;
use PhangoApp\PhaLibs\SimpleList;
use PhangoApp\PhaUtils\Utils;
use PhangoApp\PhaLibs\HierarchyLinks;
Webmodel::load_model('vendor/phangoapp/admin/models/models_admin');
I18n::load_lang('users');
function AusersAdmin()
{
    settype($_GET['op'], 'integer');
    Webmodel::$model['user_admin']->label = I18n::lang('users', 'users_admin', 'User\'s admin');
    Webmodel::$model['user_admin']->components['user_admin']->label = I18n::lang('users', 'username', 'Username');
    Webmodel::$model['user_admin']->components['privileges_user']->label = I18n::lang('users', 'privileges_user', 'Privileges');
    switch ($_GET['op']) {
        default:
            Webmodel::$model['user_admin']->create_forms();
            //Webmodel::$model['user_admin']->forms['privileges_user']->parameters=array('privileges_user', '', ChoiceAdminField::$arr_options_select);
            Webmodel::$model['user_admin']->forms['privileges_user']->arr_select = ChoiceAdminField::$arr_options_select;
            $repeat_password = new \PhangoApp\PhaModels\Forms\PasswordForm('repeat_password');
            $repeat_password->label = I18n::lang('users', 'repeat_password', 'Repeat password');
            $repeat_password->required = 1;
            Webmodel::$model['user_admin']->insert_after_field_form('password', 'repeat_password', $repeat_password);
            $admin = new GenerateAdminClass(Webmodel::$model['user_admin'], AdminUtils::set_admin_link('ausers', array('op' => 0)));
            $admin->list->arr_fields = array('IdUser_admin', 'user_admin', 'privileges_user');
            $admin->list->set_fields_showed($admin->list->arr_fields);
            $admin->list->order_field = 'IdUser_admin';
            $admin->list->order = 1;
Exemplo n.º 4
0
 public function home($module_id = 'none', $submodule_id = '')
 {
     if ($submodule_id != '') {
         $module_id = basename(Utils::slugify($module_id)) . '/' . basename(Utils::slugify($submodule_id));
     }
     class_alias('indexController', 'AdminSwitchClass');
     AdminSwitchClass::$login = new LoginClass(Webmodel::$model['user_admin'], 'user_admin', 'password', '', $arr_user_session = array('IdUser_admin', 'privileges_user', 'username', 'token_client', 'lang'), $arr_user_insert = array('user_admin', 'password', 'repeat_password', 'email'));
     AdminSwitchClass::$login->field_key = 'token_client';
     ob_start();
     //global $model, $lang, PhangoVar::$base_url, PhangoVar::$base_path, $user_data, $arr_module_admin, $config_data, $arr_block, $original_theme, $module_admin, $header;
     $header = '';
     $content = '';
     //load_libraries(array('utilities/set_admin_link'));
     //settype($module_id, 'string');
     $module_id = Utils::slugify($module_id, 1);
     $extra_urls = array();
     //Make menu...
     //Admin was internationalized
     if (AdminSwitchClass::$login->check_login()) {
         LoginClass::$session['user_admin']['token_client'] = sha1(LoginClass::$session['user_admin']['token_client']);
         if (!isset($_SESSION['language'])) {
             $_SESSION['language'] = LoginClass::$session['user_admin']['lang'];
         }
         I18n::load_lang('phangoapp/admin');
         Utils::load_config('config_admin', 'settings/admin');
         //variables for define titles for admin page
         $arr_son_module = array();
         $title_admin = I18n::lang('phangoapp/admin', 'admin', 'Admin');
         $title_module = I18n::lang('phangoapp/admin', 'home', 'Home');
         $content = '';
         $name_modules = array();
         $no_show_menu = [];
         $urls = array();
         $arr_permissions_admin = array();
         $arr_permissions_admin['none'] = 1;
         $module_admin = array();
         $arr_admin_script['none'] = AdminUtils::$admin_controller;
         //Define $module_admin[$module_id] for check if exists in database the module
         $module_admin[$module_id] = 'AdminIndex';
         //I18n::$lang[$module_admin[$module_id].'_admin']['AdminIndex_admin_name']=ucfirst(I18n::lang('phangoapp/admin', 'admin', 'Admin'));
         //0=> name in uri, 1 => route to script, 2 name of script
         $title_admin = AdminUtils::$name_admin;
         foreach (ModuleAdmin::$arr_modules_admin as $ser_admin_script) {
             //load little file lang with the name for admin. With this you don't need bloated with biggest files of langs...
             $idmodule = $ser_admin_script[0];
             $name_module = $idmodule;
             if (gettype($ser_admin_script[1]) == 'string') {
                 $name_modules[$name_module] = $ser_admin_script[2];
                 $arr_admin_script[$idmodule] = $ser_admin_script;
                 $urls[$name_module] = AdminUtils::set_admin_link($idmodule, array());
                 $module_admin[$idmodule] = $name_module;
                 $arr_permissions_admin[$idmodule] = 1;
                 if (isset($ser_admin_script[3])) {
                     $no_show_menu[$name_module] = 1;
                 }
             } else {
                 $name_modules[$name_module] = $ser_admin_script[2];
                 //unset(ModuleAdmin::$arr_modules_admin[$idmodule]['title']);
                 foreach ($ser_admin_script[1] as $ser_admin_script_son) {
                     $idmodule_son = $ser_admin_script_son[0];
                     $name_module_son = $idmodule_son;
                     $name_modules[$name_module_son] = $ser_admin_script_son[2];
                     $arr_admin_script[$idmodule_son] = $ser_admin_script_son;
                     $urls[$name_module_son] = AdminUtils::set_admin_link($idmodule_son, array());
                     $module_admin[$idmodule_son] = $name_module_son;
                     $arr_permissions_admin[$idmodule_son] = 1;
                     if (isset($ser_admin_script_son[3])) {
                         $no_show_menu[$name_module_son] = 1;
                     }
                 }
             }
         }
         if (!isset($arr_admin_script[$module_id])) {
             //Need show error.
             $this->route->response404();
             die;
         }
         //$file_include=Routes::$base_path.'/vendor/'.$arr_admin_script[ $module_id ][1].'/controllers/admin/admin_'.basename($arr_admin_script[ $module_id ][0]).'.php';
         $file_include = Routes::$base_path . '/' . $arr_admin_script[$module_id][1] . '.php';
         if (LoginClass::$session['user_admin']['privileges_user'] == 1) {
             $arr_permissions_admin = array();
             $arr_module_saved = array();
             $arr_module_strip = array();
             $arr_permissions_admin[$module_id] = 0;
             $arr_permissions_admin['none'] = 1;
             Webmodel::$model['moderators_module']->set_conditions(['where moderator=?', [$_SESSION['IdUser_admin']]]);
             $query = Webmodel::$model['moderators_module']->select(array('idmodule'), 1);
             while (list($idmodule_mod) = Webmodel::$model['moderators_module']->fetch_row($query)) {
                 //settype($idmodule_mod, 'integer');
                 $arr_permissions_admin[$idmodule_mod] = 1;
                 $arr_module_saved[] = $module_admin[$idmodule_mod];
             }
             $arr_module_strip = array_diff(array_keys($name_modules), $arr_module_saved);
             foreach ($arr_module_strip as $name_module_strip) {
                 unset($name_modules[$name_module_strip]);
                 unset($urls[$name_module_strip]);
             }
         }
         if (file_exists($file_include) && $module_admin[$module_id] != '' && $arr_permissions_admin[$module_id] == 1) {
             include $file_include;
             $func_admin = basename($module_admin[$module_id]) . 'Admin';
             if ($module_id != 'none') {
                 $title_admin = $name_modules[$module_id];
             }
             if (function_exists($func_admin)) {
                 $extra_data = $func_admin();
                 settype($extra_data, 'array');
                 $extra_data = array_merge($extra_data, $arr_son_module);
             } else {
                 throw new Exception('Error: no exists function ' . ucfirst($func_admin) . ' for admin application');
             }
         } else {
             if ($module_admin[$module_id] != '' && $arr_permissions_admin[$module_id] == 1) {
                 $output = ob_get_contents();
                 ob_clean();
                 throw new Exception('Error: no exists file ' . $file_include . ' for admin application');
                 die;
             } else {
                 $this->route->response404();
                 die;
             }
         }
         $content = ob_get_contents();
         ob_end_clean();
         if (AdminUtils::$show_admin_view == true) {
             $content = '<h1>' . $title_admin . "</h1>\n" . $content;
             echo View::load_view(array('header' => $header, 'title' => I18n::lang('phangoapp/admin', 'admin_zone', 'Admin zone'), 'content' => $content, 'name_modules' => $name_modules, 'urls' => $urls, 'extra_data' => $extra_data, 'no_show_menu' => $no_show_menu), 'admin/admin');
         } else {
             echo $content;
         }
     } else {
         $url = Routes::make_simple_url(ADMIN_FOLDER . '/login');
         die(header('Location: ' . $url, true));
     }
 }