function LoginAdminView($content) { ?> <!DOCTYPE html> <html> <head> <title><?php echo I18n::lang('users', 'login', 'Login'); ?> </title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> <?php View::$css_module['admin'][] = 'login.css'; echo View::load_js(); echo View::load_css(); echo View::load_header(); ?> </head> <body> <div id="logo_phango"></div> <div id="login_block"> <?php echo $content; ?> </div> </body> </html> <?php }
function AdminListView($admin) { echo View::show_flash(); if ($admin->list->yes_search == 1) { $admin->list->search_by_url(); $select = new SelectForm('field_search', $_GET['field_search']); //$select->arr_select=$admin->list->load_fields_showed($admin->list->arr_fields_no_search); foreach ($admin->list->arr_fields_search as $field) { $select->arr_select[$field] = Webmodel::$model[$admin->model_name]->forms[$field]->label; } if ($_GET['field_search'] == '') { $select->default_value = $admin->list->default_field_search; } $select_order = new SelectForm('order', $_GET['order']); $select_order->arr_select = array(0 => I18n::lang('common', 'asc', 'Ascendent'), 1 => I18n::lang('common', 'desc', 'Descendent')); $search = new BaseForm('search', $_GET['search']); ?> <div class="cont search"> <form method="get" action="<?php echo $admin->url; ?> "> <?php echo I18n::lang('common', 'search', 'Search'); ?> <?php echo $search->form(); ?> <?php echo $select->form(); echo $select_order->form(); ?> <input type="submit" value="<?php echo I18n::lang('common', 'search', 'Search'); ?> " /> <input type="reset" value="<?php echo I18n::lang('common', 'reset', 'Reset'); ?> " onclick="javascript:location.href='<?php echo $admin->url; ?> ';"/> </form> </div> <?php } if (!$admin->no_insert) { ?> <p><a href="<?php echo Routes::add_get_parameters($admin->url, array('op_admin' => 1)); ?> "><?php echo $admin->text_add_item; ?> </a></p> <?php } $admin->list->show(); }
function RecoveryPassFormView($model_login, $login) { ?> <h3><?php echo I18n::lang('users', 'remember_password_explain', 'Please enter the email address you registered on the website, which is where you receive your new password'); ?> </h3> <form method="post" action="<?php echo $login->url_recovery_send; ?> "> <?php Utils::set_csrf_key(); ?> <label for="email"></label> <?php echo PhangoApp\PhaModels\CoreForms::TextForm('email', ''); ?> <p><input type="submit" value="<?php echo I18n::lang('users', 'remember_password', 'Remember password'); ?> " /></p> </form> <?php }
/** * @depends testLoadLang */ public function testValueLang() { global $base_path; I18n::$base_path = $base_path; I18n::$arr_i18n = ['en-US']; I18n::$language = 'en-US'; $this->assertEquals('This is a simple text', I18n::$lang['common']['simple_text']); }
function InsertUserFormView($model_user, $model_login) { ?> <form method="post" action="<?php echo $model_login->url_insert; ?> "> <?php echo View::load_view(array($model_user->forms, $model_login->arr_user_insert), 'forms/modelform'); ?> <p><input type="submit" value="<?php echo I18n::lang('users', 'register', 'Register in the web'); ?> "/></p> </form> <?php }
public function hierarchy_links() { //Get the father and its father, and the father of its father //Obtain all id and fathers //Cache system? $arr_id_father = array(0 => 0); $arr_id_name = array(0 => I18n::lang('common', 'home', 'Home')); $arr_hierarchy = array(); $query = $this->model->select(array($this->model->idmodel, $this->parentfield_name, $this->field_name), 1); while (list($id, $father, $name) = $this->model->fetch_row($query)) { $arr_id_father[$id] = $father; $arr_id_name[$id] = $this->model->components[$this->field_name]->show_formatted($name); } $arr_hierarchy = $this->recursive_obtain_father($arr_id_father, $this->idmodel, $arr_id_name, $arr_hierarchy); $arr_hierarchy = array_reverse($arr_hierarchy); return $arr_hierarchy; //echo load_view(array($arr_hierarchy), 'common/utilities/hierarchy_links'); }
public function __construct($model, $url) { $this->model =& $model; $this->model_name = $this->model->name; $this->list = new SimpleList($this->model); $this->set_url_admin($url); $this->arr_links[''] = array($url => I18n::lang('common', 'home', 'Home')); $this->hierarchy = new HierarchyLinks($this->arr_links); $this->text_add_item = I18n::lang('common', 'add_new_item', 'Add new item'); $this->text_add_item_success = I18n::lang('common', 'add_new_item_success', 'Added new item succesfully'); $this->text_update_item = I18n::lang('common', 'update_item', 'Update item'); $this->text_updated_item = I18n::lang('common', 'item_updated', 'Item update succesfully'); $this->text_deleted_item = I18n::lang('common', 'item_deleted', 'Item deleted succesfully'); $this->text_deleted_item_error = I18n::lang('common', 'item_deleted_error', 'Error, cannot delete the field. Please, check for errors'); $this->extra_info_for_create = ''; if (count($this->model->forms) == 0) { $this->model->create_forms($this->arr_fields_edit); } }
function LoginFormView($model_user, $model_login) { //'no_expire_session' $arr_fields_login = array($model_login->field_user, $model_login->field_password); /* $model_user->forms['no_expire_session']=new ModelForm('form_login', 'no_expire_session', 'PhangoApp\PhaModels\CoreForms::CheckBoxForm', I18n::lang('users', 'automatic_login', 'Automatic login'), new BooleanField(), $required=1, $parameters=''); $model_user->forms['no_expire_session']->label_class='expire_button';*/ ?> <?php echo View::show_flash(); ?> <form method="post" action="<?php echo $model_login->url_login; ?> "> <?php Utils::set_csrf_key(); echo View::load_view(array($model_user->forms, $arr_fields_login), 'forms/modelform'); ?> <p><?php echo I18n::lang('users', 'remember_login', 'Remember login?'); ?> <input type="checkbox" name="no_expire_session" value="1" /></p> <p><a href="<?php echo $model_login->url_recovery; ?> "><?php echo I18n::lang('users', 'remember_password', 'Remember password'); ?> </a></p> <p><input type="submit" class="submit" value="<?php echo I18n::lang('common', 'login', 'Login'); ?> " /></p> </form> <?php }
function UpdateModelFormView($arr_form, $fields, $method, $action, $enctype) { ?> <form method="<?php echo $method; ?> " action="<?php echo $action; ?> " <?php echo $enctype; ?> > <?php echo View::load_view(array($arr_form, $fields), 'forms/modelform'); ?> <p><input type="submit" value="<?php echo I18n::lang('common', 'submit', 'Submit'); ?> " /></p> </form> <?php }
<?php use PhangoApp\PhaI18n\I18n; /** * Configure default internazionalitation */ I18n::$modules_path = 'vendor'; I18n::$arr_i18n = array('es-ES', 'en-US'); I18n::$language = 'en-US';
/** * An internal method used for prepare forms with repeat_password form */ public function prepare_insert_user() { $this->model_login->forms['repeat_password'] = new \PhangoApp\PhaModels\Forms\PasswordForm('repeat_password'); $this->model_login->forms['repeat_password']->label = I18n::lang('users', 'repeat_password', 'Repeat password'); $this->model_login->forms['repeat_password']->required = 1; //new ModelForm('repeat_password', 'repeat_password', 'PhangoApp\PhaModels\Coreforms::PasswordForm', I18n::lang('users', 'repeat_password', 'Repeat password'), new PasswordField(), $required=1, $parameters=''); if ($this->accept_conditions == 1) { //$this->model_login->forms['accept_conditions']=new ModelForm('form_login', 'accept_conditions', 'CheckBoxForm', I18n::lang('users', 'accept_cond_register', 'Accept registration conditions'), new BooleanField(), $required=1, $parameters=''); //$this->arr_user_insert[]='accept_conditions'; } }
use PhangoApp\PhaModels\CoreFields\ChoiceField; use PhangoApp\PhaModels\CoreFields\ForeignKeyField; use PhangoApp\PhaModels\ExtraModels\UserPhangoModel; use PhangoApp\PhaI18n\I18n; //I18n::load_lang('phangoapp/admin'); class ChoiceAdminField extends ChoiceField { public static $arr_options_formated; public static $arr_options_select; public function show_formatted($value) { return ChoiceAdminField::$arr_options_formated[$value]; } } ChoiceAdminField::$arr_options_formated = array(0 => I18n::lang('phangoapp/admin', 'administrator', 'Administrator'), 1 => I18n::lang('phangoapp/admin', 'moderator', 'Moderator')); ChoiceAdminField::$arr_options_select = array(0 => I18n::lang('phangoapp/admin', 'administrator', 'Administrator'), 1 => I18n::lang('phangoapp/admin', 'moderator', 'Moderator')); Webmodel::$model['user_admin'] = new UserPhangoModel('user_admin'); Webmodel::$model['user_admin']->register('user_admin', new CharField(255), 1); Webmodel::$model['user_admin']->register('password', new PasswordField(255), 1); Webmodel::$model['user_admin']->register('email', new EmailField(255), 1); Webmodel::$model['user_admin']->register('privileges_user', new ChoiceAdminField($size = 11, $type = 'integer', $arr_values = array(0, 1), $default_value = 1)); Webmodel::$model['user_admin']->register('token_client', new CharField(255)); Webmodel::$model['user_admin']->register('token_recovery', new CharField(255)); Webmodel::$model['user_admin']->register('lang', new ChoiceField(11, 'string', I18n::$arr_i18n), 0); Webmodel::$model['user_admin']->username = '******'; Webmodel::$model['login_tried_admin'] = new Webmodel('login_tried_admin'); Webmodel::$model['login_tried_admin']->register('ip', new CharField(255)); Webmodel::$model['login_tried_admin']->register('num_tried', new IntegerField(11)); Webmodel::$model['login_tried_admin']->register('time', new IntegerField(11)); Webmodel::$model['moderators_module'] = new Webmodel('moderators_module'); Webmodel::$model['moderators_module']->register('moderator', new ForeignKeyField(Webmodel::$model['user_admin']), 1);
public static function NoDeleteOptionsListModel($url_options, $model_name, $id) { $url_options_edit = Routes::add_get_parameters($url_options, array('op_admin' => 2, Webmodel::$model[$model_name]->idmodel => $id)); $arr_options = array('<a href="' . $url_options_edit . '">' . I18n::lang('common', 'edit', 'Edit') . '</a>'); return $arr_options; }
{ /** * A simple property that define if the admin content is showed in admin view or raw (you can use headers if you want in your admin code). */ public static $show_admin_view = true; /** * A property that define the index of admin * */ public static $admin_controller = array('admin', 'vendor/phangoapp/admin/controllers/admin/admin_admin'); /** * The name of the default admin home.You need change it if you changed the admin controller * */ public static $name_admin = ''; /** * A simple method for create urls for use in admin * * With this method you can create easily urls for your admin site * * @param string $text_admin The module to admin * @param array $parameters An array with format key value used for set get values in the new url */ public static function set_admin_link($text_admin, $parameters = array()) { #return Routes::make_module_url(ADMIN_FOLDER, 'index', 'home', array($text_admin), $get=$parameters); return Routes::make_simple_url(ADMIN_FOLDER, array($text_admin), $parameters); } } AdminUtils::$name_admin = I18n::lang('phangoapp/admin', 'admin', 'Admin');
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]");
public function register($update = 0) { $c_users = Webmodel::$model['user_admin']->select_count(); if ($c_users == 0) { ob_start(); if (Routes::$request_method == 'GET') { $this->login->create_account_form(); } else { if (Routes::$request_method == 'POST') { if ($this->login->create_account()) { View::set_flash(I18n::lang('phangoapp/admin', 'user_added_success', 'The user was added successfully')); $url_return = Routes::make_simple_url(ADMIN_FOLDER . '/login'); Routes::redirect($url_return); } else { $this->login->create_account_form(); } } } $cont_index = ob_get_contents(); ob_end_clean(); echo View::load_view(array($cont_index), 'loginadmin'); } }
function AdminIndexAdmin() { echo View::load_view(array('title' => I18n::lang('phangoapp/admin', 'welcome_to_admin', 'Welcome to admin'), 'content' => I18n::lang('phangoapp/admin', 'welcome_text', 'Welcome text')), 'admin/content'); }
function UserOptionsListModel($url_options, $model_name, $id, $arr_row) { $arr_options = SimpleList::BasicOptionsListModel($url_options, $model_name, $id, $arr_row); if ($arr_row['privileges_user'] == 1) { $arr_options[] = '<a href="' . AdminUtils::set_admin_link('ausers', array('op' => 1, 'IdUser_admin' => $id)) . '">' . I18n::lang('phangoapp/admin', 'change_user_modules', 'Change user modules') . '</a>'; } return $arr_options; }
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)); } }
function AdminView($header, $title, $content, $name_modules, $url_modules, $extra_data, $no_show_menu) { View::$js[] = 'jquery.min.js'; View::$css[] = 'font-awesome.min.css'; View::$js_module['admin'][] = 'responsive-nav.min.js'; View::$css_module['admin'][] = 'admin.css'; View::$css_module['admin'][] = 'responsive-nav.css'; ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;"> <title><?php echo $title; ?> </title> <?php echo View::load_css(); ?> <?php echo View::load_js(); ?> <?php echo View::load_header(); ?> </head> <body> <div id="logout"> <a href="<?php echo AdminUtils::set_admin_link('login/logout'); ?> "><i class="fa fa-power-off" aria-hidden="true"></i> Logout</a> </div> <div id="center_body"> <div id="header"> <a href="#nav" id="toggle"><i class="fa fa-bars" aria-hidden="true"></i><span>Menu</span></a> <span id="title_phango">Phango</span> <span id="title_framework">Framework!</span> <div id="languages_general"> <?php $arr_selected = array(); foreach (I18n::$arr_i18n as $lang_item) { //set $arr_selected[Utils::slugify($lang_item)] = 'no_choose_flag_general'; $arr_selected[Utils::slugify(I18n::$language)] = 'choose_flag_general'; ?> <a class="<?php echo $arr_selected[Utils::slugify($lang_item)]; ?> " href="<?php echo Routes::make_module_url('lang', 'index', 'home', array('language' => $lang_item)); ?> "><img src="<?php echo View::get_media_url('images/languages/' . $lang_item . '.png'); ?> " alt="<?php echo $lang_item; ?> "/></a> <?php } ?> </div> </div> <div class="content_admin"> <nav id="menu" class="nav-collapse"> <ul> <li class="menu_title"><i class="fa fa-gear" aria-hidden="true"></i> <?php echo I18n::lang('phangoapp/admin', 'applications', 'Applications'); ?> </li> <?php foreach ($name_modules as $key_module => $name_module) { if (!isset($no_show_menu[$key_module])) { if (isset($url_modules[$key_module])) { ?> <li><a href="<?php echo $url_modules[$key_module]; ?> "><i class="fa fa-circle-o" aria-hidden="true"></i> <?php echo $name_module; ?> </a></li> <?php } else { echo '<li><div class="father_admin">' . $name_module . '</div></li>'; } } //If have $key_module with an extra_url element from extra_data, put here. if (isset($extra_data['extra_url'][$key_module])) { foreach ($extra_data['extra_url'][$key_module]['url_module'] as $key => $url_module) { ?> <li><a class="sub_module" href="<?php echo $url_module; ?> "> <i class="fa fa-circle-o" aria-hidden="true"></i> <?php echo ucfirst($extra_data['extra_url'][$key_module]['name_module'][$key]); ?> </a></li> <?php } } } ?> </ul> </nav> <div class="contents"> <?php echo View::show_flash(); ?> <?php echo $content; ?> </nav> </div> </div> <div id="loading_ajax"> </div> <script> var navigation = responsiveNav(".nav-collapse", {customToggle: "#toggle"}); </script> </body> </html> <?php }