meraproject/themes/merakomis/dictionary/step/controller.php
keboss-m 5c21d25d45 Initial commit: Merakomis portal, Docker stack and user-reader API.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-24 11:04:05 +03:00

74 lines
3.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
namespace controller\themes\merakomis\dictionary\step;
use core\core\structure\eRowClick;
use ms\ms\structure\msControllerTable;
use themes\Merakomis;
use themes\merakomis\dictionary\Section;
use themes\merakomis\dictionary\Step;
use themes\merakomis\Emp;
use themes\merakomis\structure\merakomisControllerTable;
class Api extends merakomisControllerTable {
static $class = 'themes\merakomis\dictionary\Step';
static function getData(){
$res = [];
if(Emp::$IS_AUTH){
$id = intval($_POST['id']);
$step = Step::getByID($id);
$sections = [0=>['id'=>0,'name'=>'Главный раздел']];
$structure = [0=>[]];
$r = Section::select([
\Query::WHERE => new \Where(\Where::_and([
\Where::_operator(Section::$STEP,'=',$id)
])),
\Query::SORT =>[Section::$PARENT=>'ASC'],
]);
while($l = \DB::fetch($r)){
$id = intval($l[Section::$ID]);
$pid = intval($l[Section::$PARENT]);
$sections[$id] = ['id'=>$id,'name'=>Section::getName($l)];
$structure[$pid][] = $id;
}
$res = [
'id'=>intval($id),
'name'=>Step::getName($step),
'text'=>$step[Step::$TEXT],
'vis'=>boolval($step[Step::$VIS]),
'sections'=>$sections,
'structure'=>$structure,
];
}
echo je($res);
}
public static function getTableData($post = []) {
$post['options'][\ModuleTable::ROW_CLICK] = eRowClick::NONE;
//$TITLE= ['title'=>'Структура проекта','subtitle'=>'Заголовок','text'=>'Компьютеры коренным образом изменили жизнь каждого человека. Несколько десятилетий назад люди даже не знали ничего об этих электронных устройствах, тогда как в наши дни даже маленький ребенок может управлять этой машиной. Почти все современные технологии зависит от компьютеров, которые используются для хранения данных: файлов, секретной информации, банковских операций и прочего.'];
$post['getData'] = true;
$res = parent::getTableData($post);
//$res['title'] = $TITLE;
//$res['title'] = ['title'=>'Структура проекта','subtitle'=>Merakomis::$STEP_TABLE_SUBTITLE,'text'=>Merakomis::$STEP_TABLE_TEXT];
$res['title'] = [
'title' => 'Структура проекта',
'edit' => true,
'subtitle' => Merakomis::$STEP_TABLE_SUBTITLE,
'text' => Merakomis::$STEP_TABLE_TEXT,
'subtitle_var' => Merakomis::$_STEP_TABLE_SUBTITLE,
'text_var' => Merakomis::$_STEP_TABLE_TEXT,
];
echo je($res);
}
}