This commit is contained in:
indeferend
2021-05-23 06:26:34 +05:00
commit df825e3d2f
56 changed files with 24076 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
<?php
LE::$TPL->prefix="admin";

94
MODULES/admin/blog.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
class CONTR extends LE_MOD_CONTROLLER {
protected function check_dest_folder($f)
{
if (!is_dir($uploaddir))
if(mkdir($uploaddir,0777,true)===false)
return false;
return true;
}
protected function _ajx_add_img($data)
{
if (!isset($_FILES['upload'])) return false;
$dest = WEBDIR.'pub_data/upload/img/';
if (!$this->check_dest_folder($dest)) return false;
$filename = LE_FS::SAVE_POST(['f_name'=>'upload','path'=>$dest]);
return ['url'=>'/pub_data/upload/img/'.$filename, 'as_is'=>1];
}
protected function _ajx_save_content($data)
{
$id = PRE::INT($data['id']);
$html_cont = $data['html_cont'];
preg_match('!(<h1>(.*?)<\/h1>)?(.*)!simu',$html_cont,$out);
$html_cont = $out[3];
$html_head = trim($out[2]);
//return;
$save_data = ['id'=>$id,'html'=>$html_cont,'head'=>$html_head];
$id = LE::$DB->SAVE('text_content',$save_data);
return $id;
}
protected function _ajx_remove_it($inp)
{
if (!isset($inp['id'])) return false;
$id=PRE::INT($inp['id']);
if (!$id>0) return false;
$res = LE::$DB->DEL('text_content',$id);
return ($res>0);
}
protected function _inp_default($inp)
{
$res = LE::$DB->query_arr("SELECT * FROM `text_content`",'id');
$to_tpl['cont_list'] = $res;
return LE::$TPL->fetch('blog/list',$to_tpl);
}
protected function _inp_edit($inp)
{
$id = PRE::INT($inp);
if ($id>0)
{
$res = LE::$DB->query_single("SELECT * FROM `text_content` WHERE `id`=".$id);
$it_data = json_decode($res['data'],1);
}
else
{
$res = ['html'=>'','head'=>''];
$it_data = [];
$id=0;
}
$to_tpl = [
'data'=>$it_data,
'id'=>$id,
'html_cont'=>$res['html'],
'head'=>$res['head']
];
return LE::$TPL->fetch('blog/edit_item',$to_tpl);
}
}
include CLSDIR."blog.php";
$blog_model = new blog_model;
$controller = new CONTR($le_mod_loader->url,$blog_model);
LE::$TPL->mod_cont .= $controller->start();

3
MODULES/main/__404.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
http_response_code(404);
echo "<h1>PAGE NOT FOUND</h1>";

View File

View File

@@ -0,0 +1,68 @@
<?php
class CONTR extends LE_MOD_CONTROLLER {
protected function _ajx_upload_img($data)
{
if (!isset($_FILES['upl_img'])) return false;
$uploaddir = WEBDIR.'pub_data/upload/img/';
if (!is_dir($uploaddir))
if(mkdir($uploaddir,0777,true)===false)
return false;
$filename = LE_FS::SAVE_POST(['f_name'=>'upl_img','path'=>$uploaddir]);
return ['url'=>'/pub_data/upload/img/'.$filename];
}
protected function _ajx_save_content($data)
{
$md_cont = $data['md_cont'];
$id = PRE::INT($data['id']);
$_data = json_encode(['md_cont'=>$md_cont]);
$html_cont = $data['html_cont'];
$save_data = ['id'=>$id,'data'=>$_data,'html'=>$html_cont];
$id = LE::$DB->SAVE('text_content',$save_data);
return $id;
}
protected function _inp_default($inp)
{
$res = LE::$DB->query_arr("SELECT * FROM `text_content`",'id');
$to_tpl['cont_list'] = $res;
return LE::$TPL->fetch('le_ui_kit/editor_list',$to_tpl);
}
protected function _inp_edit($inp)
{
$id = PRE::INT($inp);
if (!$id>0) return false;
$res = LE::$DB->query_single("SELECT * FROM `text_content` WHERE `id`=".$id);
$it_data = json_decode($res['data'],1);
$to_tpl = compact('it_data','res','id');
$to_tpl['md_cont'] = (isset($it_data['md_cont'])) ? $it_data['md_cont'] : '';
return LE::$TPL->fetch('le_ui_kit/test_ckeditor',$to_tpl);
//return LE::$TPL->fetch('le_ui_kit/test_editor',$to_tpl);
}
}
//echo_arr($le_mod_loader->url);
$controller = new CONTR($le_mod_loader->url);
//$mod_out = $controller->start();
LE::$TPL->mod_cont .= $controller->start();

0
MODULES/main/shop.php Normal file
View File

View File

@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LE UIKit</title>
<link rel="stylesheet" type="text/css" href="/assets/css/le_uikit.css" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<?/*
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<!-- JavaScript Bundle with Popper -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<link rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
*/?>
<link rel="stylesheet"
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/highlight.min.js"></script>
<link rel="stylesheet" href="/pub/css/le_form.css">
<script src="https://cdn.ckeditor.com/ckeditor5/27.1.0/classic/ckeditor.js"></script>
<!-- Editor's Dependecy Style -->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.min.css"
/>
<!-- Editor's Style -->
<link rel="stylesheet" href="https://uicdn.toast.com/editor/latest/toastui-editor.min.css" />
</head>
<body>
<div id="page_cont" style="max-width:1000px;margin:10px auto;padding:10px;">
<button type="button" class="btn btn-primary">Button</button>
<form class="le_form le_shadow">
<span class="le_form_head">Заголовок формы</span>
<div class="le_he">
<label for="inp_name" class="le_fl"><span>Горизонтальный инпут</span></label>
<div class="le_inp"><input type="text" value="kokoko" id="inp_name"></div>
</div>
<div class="le_ve">
<label for="inp_name" class="le_fl"><span>Вертикальный инпут</span></label>
<div class="le_inp"><input type="text" value="kokoko" id="inp_name"></div>
</div>
<div class="le_he">
<label for="inp_name" class="le_fl"><span>Горизонтальный инпут у которого допустим пару строчек, строчки тут две <sup>*</sup></span></label>
<div class="le_inp"><input type="text" value="kokoko" id="inp_name"></div>
</div>
<div class="le_he">
<div for="select_koko" class="le_fl"><span>Горизонтальный селект</span></div>
<div class="le_inp">
<select id="select_koko">
<option>select</option>
<option>select</option>
<option>select</option>
<option>select</option>
<option>select</option>
</select>
</div>
</div>
<div class="le_he le_me">
<div for="inp_name" class="le_fl"><span>Радиокнопки</span></div>
<div class="le_inp">
<label><input type="radio" name="radio1">Radio1</label>
<label><input type="radio" name="radio1">Radio2</label>
</div>
</div>
<div class="le_ve le_me">
<div for="inp_name" class="le_fl"><span>Радиокнопки вертикально</span></div>
<div class="le_inp">
<label><input type="radio" name="radio1">Radio1</label>
<label><input type="radio" name="radio1">Radio2</label>
</div>
</div>
<div class="le_he le_me">
<div for="inp_name" class="le_fl"><span>Чекбоксы<sup>*</sup></span></div>
<div class="le_inp">
<label><input type="checkbox" name="checkbox1">checkbox1</label>
<label><input type="checkbox" name="checkbox1">checkbox2</label>
</div>
</div>
<div class="le_he le_me le_meh">
<div for="inp_name" class="le_fl"><span>Радиокнопки в линию</span></div>
<div class="le_inp">
<label><input type="radio" name="radio1">Radio1</label>
<label><input type="radio" name="radio1">Radio2</label>
</div>
</div>
<div class="le_he">
<label for="inp_name" class="le_fl"><span>Дата <sup>*</sup></span></label>
<div class="le_inp"><input type="date" value="kokoko" id="inp_name"></div>
</div>
<div class="le_ve">
<label for="inp_name" class="le_fl"><span>Текст</span></label>
<div class="le_inp"><textarea class="cktxt">тролололо</textarea></div>
</div>
<div class="le_he">
<label for="inp_name" class="le_fl"><span>Текст горизонтально</span></label>
<div class="le_inp"><textarea>тролололо</textarea></div>
</div>
<div class="le_ve">
<label for="inp_name" class="le_fl"><span>Текст</span></label>
<div class="le_inp"><textarea class="tu-editor">тролололо</textarea></div>
</div>
<div class="le_bbl">
<button type="submit">Сохранить</button>
<button class="le_btn_blue" type="submit">Синяя</button>
<button class="le_btn_red" type="submit">Красная</button>
<button class="le_btn_green" type="submit">Зеленая</button>
</div>
</form>
<br>
<br>
<br>
<br>
<h2>Markdown Editor from ToastUI</h2>
<div id="editor"></div>
<a href="#" onclick="alert(editor.getHtml()); return false;">html get</a> |
<a href="#" onclick="alert(editor.getMarkdown()); return false;">markdown get</a> |
<a href="#" onclick="hljs.highlightAll(); return false;">Code hilight</a> |
</div>
<script>
/*ClassicEditor
.create( document.querySelector( '.cktxt' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
*/
</script>
<script src="https://uicdn.toast.com/editor/latest/toastui-editor-all.min.js"></script>
<script>
const editor = new toastui.Editor({
el: document.querySelector('#editor'),
previewStyle: 'vertical',
height: '500px',
initialValue: '### hello world \n```\n<?="<?"?>php\n```'
});
editor.on('change',function(e){
/*hljs.highlightAll();*/
document.querySelectorAll('div.te-preview pre').forEach(block => {
// then highlight each
hljs.highlightBlock(block);
});
});
</script>
</body>
</html>

33
MODULES/main/ui_test.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
/*
1. Подключить нужные для модуля классы и конфиги
2. Определить какой метод контроллера выполнить и запустить его
3. Внутри метода идет вывод или запись данных, при выводе передается в шаблон
4. Содержимое
*/
//compute
//if (isset($_POST)) echo_arr($_POST);
//if (isset($_FILES)) echo_arr($_FILES);
if (isset($_FILES['upl_img']))
{
$uploaddir = WEBDIR.'pub_data/upload/img/';
$f_name=basename($_FILES['upl_img']['name']);
$uploadfile = $uploaddir . basename($_FILES['upl_img']['name']);
if (move_uploaded_file($_FILES['upl_img']['tmp_name'], $uploadfile))
{
$out = ['success'=>1];
$out['data'] = ['url'=>'/pub_data/upload/img/'.$f_name];
$mod_out = json_encode($out);
}
}
else
$mod_out = LE::$TPL->fetch('le_ui_kit/test1');
//out to tpl
LE::$TPL->mod_cont .= $mod_out;

1
MODULES/main/welcome.php Normal file
View File

@@ -0,0 +1 @@
Добро пожаловать в новый мир!!!