public function get_list_of_modules() { $modules['all'] = '-- ' . \CORE::t('all', 'все') . ' --'; $type = array(' (core)', ' (app)'); foreach (\CORE::init()->get_modules() as $key => $value) { $modules[$key] = $key . $type[(int) $value]; } return $modules; }
public function main($model) { $lang = \CORE::lng(); $UI = \CORE\UI::init(); $result = '<div><h4>' . \CORE::t('mt', 'Образовательные учреждения') . ':</h4></div>'; $mt = $model->get_mt(); $mt_types = $model->get_mt_types(); $mt_count = count($mt); $result .= '<p><strong>' . \CORE::t('filter', 'Фильтр') . ':</strong> ' . \CORE::t('types', 'Типы') . ' ' . $UI->html_list($mt_types, '', ' id="type"', $model->selected_type, '-- ' . \CORE::t('all', 'Все') . ' --') . '<p>'; $result .= '<p>' . $UI->bootstrap_modal_btn('show_newModal', 'newModal', \CORE::t('add_mt', 'Добавить учреждение')) . '</p>'; if ($mt_count > 0) { $geo = $model->get_geo_objects(); $result .= ' <table class="table table-bordered table-hover" style="width:auto;"> <thead> <tr> <th>№</th> <th>' . \CORE::t('type', 'Тип') . '</th> <th>' . \CORE::t('mt_name', 'Название учреждения') . '</th> <th>ID</th> <th>' . \CORE::t('geo', 'География') . '</th> <th>' . \CORE::t('address', 'Адрес') . '</th> <th class="text-center">' . \CORE::t('action', 'Действие') . '</th> </tr> </thead> <tbody> '; $cnt = 0; foreach ($mt as $mt_id => $mt_val) { $cnt++; $mt_type = ''; if (isset($mt_types[$mt_val['mt-type']])) { $mt_type = $mt_types[$mt_val['mt-type']]; } $mt_geo = ''; if (isset($geo[$mt_val['mt-geo-id']])) { $mt_geo = $geo[$mt_val['mt-geo-id']]; } $result .= ' <tr> <td>' . $cnt . '</td> <td>' . $mt_type . '</td> <td>' . $mt_val['mt-name-' . $lang] . '</td> <td>' . $mt_id . '</td> <td>' . $mt_geo . '</td> <td>' . $mt_val['mt-address'] . '</td> <td> <div id="' . $mt_id . '" class="btn-group btn-group-xs"> <button type="button" class="btn btn-default edit" data-toggle="modal" data-target="#editModal">' . \CORE::t('edit', 'изменить') . '</button> <button type="button" class="btn btn-default delete">' . \CORE::t('delete', 'удалить') . '</button> </div> </td> </tr> '; } $result .= '</tbody> </table> '; } else { \CORE::msg('info', \CORE::t('no_mt', 'В базе не найдены образовательные учреждения')); } $geo_info = ''; $geo_list = $model->get_gid_geo_objects(); if (count($geo_list) > 0) { // totdo !!! change for all groups - gid $geo_info = ' <div class="form-group"> <label for="new_geo">' . \CORE::t('location', 'Расположение') . '</label> ' . $UI->html_list($geo_list, '', ' id="new_geo" class="form-control"') . ' </div>'; } $new_body = $geo_info . ' <div class="form-group"> <label for="new_type">' . \CORE::t('type', 'Тип') . '</label> ' . $UI->html_list($mt_types, '', ' id="new_type" class="form-control"', $model->selected_type) . ' </div> <div class="form-group"> <label for="new_name_ru">' . \CORE::t('mt_name', 'Название учреждения') . ' (RU)</label> <input type="text" class="form-control" id="new_name_ru" placeholder="Название"> </div> <div class="form-group"> <label for="new_name_tj">' . \CORE::t('mt_name', 'Название учреждения') . ' (TJ)</label> <input type="text" class="form-control" id="new_name_tj" placeholder="Номи муассиса"> </div> <div class="form-group"> <label for="new_director">Директор</label> <input type="text" class="form-control" id="new_director" placeholder="Ф.И.О."> </div> <div class="form-group"> <label for="new_address">' . \CORE::t('address', 'Адрес') . '</label> <input type="text" class="form-control" id="new_address" placeholder="' . \CORE::t('address', 'Адрес') . '"> </div> <div class="form-group"> <label for="new_phone">Телефон</label> <input type="text" class="form-control" id="new_phone" placeholder=""> </div> <div class="form-group"> <label for="new_mobile">' . \CORE::t('mobile', 'Мобильный') . '</label> <input type="text" class="form-control" id="new_mobile" placeholder="9XXXXXXXX"> </div> <hr> <div class="form-group"> <div class="row"> <div class="col-md-6"> <label for="new_geo_lat">Latitude</label> <input type="text" class="form-control" id="new_geo_lat" placeholder="38.XXXXXXX"> </div> <div class="col-md-6"> <label for="new_geo_lng">Longitude</label> <input type="text" class="form-control" id="new_geo_lng" placeholder="68.XXXXXXX"> </div> </div> </div> '; $result .= $UI->bootstrap_modal('newModal', \CORE::t('new_mt', 'Новое учреждение') . ':', '', $new_body, 'addNew', \CORE::t('add', 'Добавить')); $UI->pos['js'] .= ' <script> $(document).ready(function() { $("#type").change(function(){ var sel_type = $(this).val(); if(sel_type>0){ window.location.href="./?c=mt&type="+sel_type; } else { window.location.href="./?c=mt"; } }); $("#addNew").click(function(e){ e.preventDefault(); alert("add..."); }); $(".edit").click(function(){ var edit_id = $(this).parent("div").attr("id"); }); $(".delete").click(function(){ var del_id = $(this).parent("div").attr("id"); if(confirm("' . \CORE::t('delete', "Удалить") . '?")){ $.post("./?c=mt&act=del&ajax", {id: del_id}, function(data){ if(data=="deleted"){ location.reload(); } else { alert("Error, check js log..."); console.log(data); } }); } }); }); </script> '; return $result; }
public function main($model) { $UI = \CORE\UI::init(); $modules_list = $model->get_list_of_modules(); $result = '<div> <h4>' . mb_convert_case(\CORE::t('translation', 'Translation'), MB_CASE_TITLE, "UTF-8") . ':</h4> ' . \CORE::t('module', 'Модуль') . ': ' . $UI->html_list($modules_list, '', ' id="sel_module"', $model->sel_module) . ' <!-- (Ҷҷ, Ӯӯ, Ққ, Ӣӣ, Ғғ, Ҳҳ) --> ' . $UI::bootstrap_modal_btn('add_new_translation', 'new_translation', \CORE::t('new_translation', 'Новый перевод')) . ' </div><br>'; $translations = $model->get_translations($model->sel_module); $translations_counter = count($translations); // modal: new $new_translation_body = ' <div class="form-group"> <label for="alias">Alias</label> <input type="text" class="form-control" id="alias" placeholder="short_latin_txt" style="width:200px;"> </div> <div class="form-group"> <label for="ru_txt">RU</label> <input type="text" class="form-control" id="ru_txt" placeholder="Перевод"> </div> <div class="form-group"> <label for="tj_txt">TJ</label> <input type="text" class="form-control" id="tj_txt" placeholder="Тарҷума"><br> <span class="text-muted">Ҷҷ, Ӯӯ, Ққ, Ӣӣ, Ғғ, Ҳҳ</span> </div> '; $result .= $UI::bootstrap_modal('new_translation', \CORE::t('new_translation', 'Новый перевод') . ':', '', $new_translation_body, 'create_new_translation', \CORE::t('add', 'Добавить')); $UI->pos['js'] .= ' <script> $(document).ready(function() { function IsJsonString(str) { try { JSON.parse(str); } catch(e) { return false; } return true; } $("#sel_module").change(function(){ window.location.href = "./?c=translation&sel_module=" + $(this).val(); }); $("#create_new_translation").click(function(e){ e.preventDefault(); var new_alias=$("#alias").val(); var new_ru=$("#ru_txt").val(); var new_tj=$("#tj_txt").val(); $.post("./?c=translation&act=add&sel_module="+$("#sel_module").val()+"&ajax", {alias: new_alias, ru: new_ru, tj: new_tj}, function(data){ if(data=="created"){ location.reload(); } else { alert("Error, check js log..."); console.log(data); } }); }); $(".edit_translation").click(function(e){ var get_module=$("#sel_module").val(); var get_alias=$(this).parent("div").attr("id"); $.post("./?c=translation&act=get&ajax", {module: get_module, alias: get_alias}, function(data){ if(IsJsonString(data)){ var obj = JSON.parse(data); $("#edit_module").val(obj.module); $("#edit_alias").val(obj.alias); $("#edit_ru_txt").val(obj.ru); $("#edit_tj_txt").val(obj.tj); } else { alert("Error, check js log..."); console.log(data); } }); }); $("#update_translation").click(function(e){ e.preventDefault(); var edit_module=$("#edit_module").val(); var edit_alias=$("#edit_alias").val(); var edit_ru=$("#edit_ru_txt").val(); var edit_tj=$("#edit_tj_txt").val(); $.post("./?c=translation&act=update&ajax", {module: edit_module, alias: edit_alias, ru: edit_ru, tj: edit_tj}, function(data){ if(data=="updated"){ location.reload(); } else { alert("Error, check js log..."); console.log(data); } }); }); $(".del_translation").click(function(){ var del_alias = $(this).parent("div").attr("id"); if(confirm("' . \CORE::t('delete', 'Удалить') . '?")){ $.post("./?c=translation&act=del&sel_module="+$("#sel_module").val()+"&ajax", {alias: del_alias}, function(data){ if(data=="deleted"){ location.reload(); } else { alert("Error, check js log..."); console.log(data); } }); } }); }); </script>'; if ($translations_counter > 0) { $result .= ' <table class="table table-bordered table-hover" style="width:auto;"> <thead> <tr> <th>№</th> <th>' . \CORE::t('alias', 'Псевдоним') . '</th> <th>RU</th> <th>TJ</th> <th class="text-center">' . \CORE::t('action', 'Действие') . '</th> </tr> </thead> <tbody> '; $cnt = 0; foreach ($translations as $alias => $t_array) { $cnt++; $result .= ' <tr> <td>' . $cnt . '</td> <td>' . $alias . '</td> <td>' . $t_array['ru'] . '</td> <td>' . $t_array['tj'] . '</td> <td> <div id="' . $alias . '" class="btn-group btn-group-xs"> <button type="button" class="btn btn-default edit_translation" data-toggle="modal" data-target="#editModal">' . \CORE::t('edit', 'изменить') . '</button> <button type="button" class="btn btn-default del_translation">' . \CORE::t('delete', 'Удалить') . '</button> </div> </td> </tr> '; } $result .= '</tbody> </table> <span class="text-muted"> P.S. Example of using this in the code: CORE::t("alias","Default translation"); </span> '; // modal: edit $edit_translation_body = ' <div class="form-group"> <label for="edit_module">' . \CORE::t('module', 'Модуль') . '</label> ' . $UI->html_list($modules_list, '', ' id="edit_module" class="form-control" disabled', $model->sel_module) . ' </div> <div class="form-group"> <label for="edit_alias">' . \CORE::t('alias', 'Псевдоним') . '</label> <input type="text" class="form-control" id="edit_alias" placeholder="short_latin_txt" style="width:200px;" disabled> </div> <div class="form-group"> <label for="edit_ru_txt">RU</label> <input type="text" class="form-control" id="edit_ru_txt" placeholder="Перевод"> </div> <div class="form-group"> <label for="edit_tj_txt">TJ</label> <input type="text" class="form-control" id="edit_tj_txt" placeholder="Тарҷума"><br> <span class="text-muted">Ҷҷ, Ӯӯ, Ққ, Ӣӣ, Ғғ, Ҳҳ</span> </div> '; $result .= $UI::bootstrap_modal('editModal', \CORE::t('edit', 'Редактирование') . ':', '', $edit_translation_body, 'update_translation', \CORE::t('update', 'Обновить')); } else { $result .= '<h4 class="text-danger">' . \CORE::t('no_translations_yet', 'Здесь пока нет переводов') . '</h4>'; } return $result; }
public function show() { \CORE::msg('debug', 'umenu'); $UI = \CORE\UI::init(); $USER = \USER::init(); $UI->pos['js'] .= ' <script> $(document).ready(function() { function change_language(xlang){ $.post("./?lang="+xlang, function(){ location.reload(); }); } $("a.change_language").click(function(e){ e.preventDefault(); var xlang = $(this).attr("rel"); change_language(xlang); }); }); </script> '; if ($USER->auth()) { // authorized users $UI->pos['mainmenu'] .= ' <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('reports', 'Отчеты') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li class="dropdown-header">' . \CORE::t('input_forms', 'Формы ввода данных:') . '</li> <li class="divider"></li> <li><a href="./?c=frm&act=ps">' . \CORE::t('mt_frm_passport', 'Паспорт образовательного учреждения') . '</a></li> <li><a href="./?c=frm&act=bmt1">' . \CORE::t('mt_frm_bmt1', 'Форма БМТ-1') . '</a></li> <li><a href="./?c=frm&act=kom1">' . \CORE::t('mt_frm_kom1', 'Форма КОМ-1') . '</a></li> <li><a href="./?c=frm&act=tm1">' . \CORE::t('mt_frm_tm1', 'Форма ОШ-1') . '</a></li> <li><a href="./?c=frm&act=fb">' . \CORE::t('mt_frm_fb', 'Форма ФБ') . '</a></li> <li><a href="./?c=frm&act=km1">' . \CORE::t('mt_frm_km1', 'Форма КМ-1') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('statistic', 'Статистика') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=stat">----</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('visualization', 'Визуализация') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=map">' . \CORE::t('map', 'Карта') . '</a></li> <li><a href="./?c=vs">' . \CORE::t('datavisual', 'Визуализация данных') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('opendata', 'Открытые данные') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=page&act=about_opendata">' . \CORE::t('about_opendata', 'Об открытых данных') . '</a></li> <li><a href="./?c=od">' . \CORE::t('opendata', 'Открытые данные') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('zayavki', 'Заявки') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=apps&act=create">' . \CORE::t('reg_form', 'Форма регистрации') . '</a></li> <li><a href="./?c=apps&act=status_check">' . \CORE::t('check_app', 'Проверить статус заявки') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('project', 'Проект') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=page&act=about">' . \CORE::t('about_project', 'Описание проекта') . '</a></li> <li><a href="./?c=page&act=team">' . \CORE::t('project_team', 'Команда проекта') . '</a></li> </ul> </li> '; $UI->pos['user1'] .= ' <ul class="nav navbar-nav"> ' . LANGUAGE::SWITCHER(true) . ' <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> <small><i class="glyphicon glyphicon-cog"></i> </small> ' . $USER->get('username') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <!--<li> <a href="./?c=user&act=profile"> <small><i class="glyphicon glyphicon-user"></i> </small> <span class="text">' . \CORE::t('profile', 'Профиль') . '</span> </a> </li>--> <!--<li> <a href="./?c=user&act=change_password"> <small><i class="glyphicon glyphicon-pencil"></i> </small> <span class="text">' . \CORE::t('cpasswd', 'Сменить пароль') . '</span> </a> </li> --> <li class="divider"></li> <li> <a href="./?c=user&act=logout"> <small><i class="glyphicon glyphicon-off"></i> </small> <span class="text">' . \CORE::t('logout', 'Logout') . '</span> </a> </li> </ul> </li> </ul> '; } else { // guests $UI->pos['mainmenu'] .= ' <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('visualization', 'Визуализация') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=map">' . \CORE::t('map', 'Карта') . '</a></li> <li><a href="./?c=vs">' . \CORE::t('datavisual', 'Визуализация данных') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('opendata', 'Открытые данные') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=page&act=about_opendata">' . \CORE::t('about_opendata', 'Об открытых данных') . '</a></li> <li><a href="./?c=od">' . \CORE::t('opendata', 'Открытые данные') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('zayavleniya', 'Заявления') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=apps&act=create">' . \CORE::t('reg_form', 'Форма регистрации') . '</a></li> <li><a href="./?c=apps&act=status_check">' . \CORE::t('check_app', 'Проверить статус заявки') . '</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> ' . \CORE::t('about', 'О проекте') . ' <span class="caret"></span></a> <ul class="dropdown-menu"> <li><a href="./?c=page&act=about">' . \CORE::t('about_project', 'Описание проекта') . '</a></li> <li><a href="./?c=page&act=team">' . \CORE::t('team', 'Команда проекта') . '</a></li> </ul> </li> '; $UI->pos['user1'] .= '<form action="./?c=user&act=login" method="post" class="navbar-form"> ' . LANGUAGE::SWITCHER(); $UI->pos['user1'] .= '<div class="form-group"> <input type="text" name="login" placeholder="' . \CORE::t('login', 'Login') . '" value="' . \COOKIE::get('lastuser') . '" class="form-control" style="width:150px;"> </div> <div class="form-group"> <input type="password" name="password" placeholder="' . \CORE::t('password', 'Password') . '" class="form-control" style="width:150px;"> </div> <button type="submit" class="btn btn-warning">' . \CORE::t('login', 'Login') . '</button> '; $UI->pos['user1'] .= '</form> '; } }
<?php $this->pos['main'] = ' <div class="row"> <div class="col-md-4"> <ul class="nav nav-pills nav-stacked" style="border-radius: 4px;border: 1px solid #e2e2e2;box-shadow: 5px 5px 10px 0px rgba(204,204,204,1);"> <li class="active"><a href="./">' . \CORE::t('system', 'Система') . '</a></li> <li><a href="./?c=group">' . \CORE::t('groups', 'Группы') . '</a></li> <li><a href="./?c=users">' . \CORE::t('users', 'Пользователи') . '</a></li> <!--<li><a href="./?c=acl">' . \CORE::t('access', 'Доступ') . '</a></li>--> <li><a href="./?c=translation">' . \CORE::t('translation', 'Перевод') . '</a></li> </ul> </div> <div class="col-md-4"> <ul class="nav nav-pills nav-stacked" style="border-radius: 4px;border: 1px solid #efefef;box-shadow: 5px 5px 10px 0px rgba(204,204,204,1);"> <li class="active"><a href="./">' . \CORE::t('mt', 'Образовательные учреждения') . '</a></li> <li><a href="./?c=mt">' . \CORE::t('mt_list', 'Список учреждений') . '</a></li> <!--<li><a href="./?c=geo">' . \CORE::t('geo', 'География') . '</a></li>--> <!--<li><a href="./?c=map&manage">' . \CORE::t('map', 'Карта') . '</a></li>--> </ul> </div> <div class="col-md-4"></div> </div> ';
public static function bootstrap_modal($id = 'myModal', $title = 'Modal title', $frm = '', $body = '...', $btn_id = 'defaultAction', $btn_txt = 'Save changes') { $result = ' <!-- Modal -> ' . $id . ' --> <div class="modal fade" id="' . $id . '" tabindex="-1" role="dialog" aria-labelledby="' . $id . 'Label" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <form' . $frm . '> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">×</span></button> <h4 class="modal-title" id="' . $id . 'Label">' . $title . '</h4> </div> <div id="' . $id . 'Body" class="modal-body"> ' . $body . ' </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">' . \CORE::t('close', 'Close') . '</button> <input type="submit" id="' . $btn_id . '" class="btn btn-primary" value="' . $btn_txt . '"> </div> </form> </div> </div> </div> <!-- /Modal -> ' . $id . ' --> '; return $result; }