chore: Аннотации к типам
This commit is contained in:
parent
09a61244ca
commit
1e27648a12
17 changed files with 217 additions and 81 deletions
|
|
@ -8,6 +8,14 @@ namespace ctiso\View;
|
|||
class Pages
|
||||
{
|
||||
static int $range = 5;
|
||||
|
||||
/**
|
||||
* @param int $page номер страницы
|
||||
* @param int $onpage количество страниц на странице
|
||||
* @param int $count количество всех страниц
|
||||
* @param string $prefix префикс
|
||||
* @return array{'all': bool, 'list': array, 'first': string, 'last': string, 'next': string, 'prev': string}
|
||||
*/
|
||||
static function getPages($page, $onpage, $count, $prefix = '?')
|
||||
{
|
||||
$n = ceil($count / $onpage);
|
||||
|
|
@ -51,6 +59,11 @@ class Pages
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prefix префикс
|
||||
* @param string $x строка
|
||||
* @return string
|
||||
*/
|
||||
static function href($prefix, $x) {
|
||||
return $prefix . $x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,35 +7,60 @@ namespace ctiso\View;
|
|||
*/
|
||||
class Plain extends \stdClass
|
||||
{
|
||||
/** @var string */
|
||||
protected $document;
|
||||
/** @var array */
|
||||
protected $values = [];
|
||||
|
||||
/**
|
||||
* Конструктор
|
||||
* @param string $document шаблон
|
||||
*/
|
||||
public function __construct ($document)
|
||||
{
|
||||
$this->document = $document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка значения
|
||||
* @param string $key ключ
|
||||
* @param mixed $value значение
|
||||
*/
|
||||
public function set($key, $value)
|
||||
{
|
||||
$this->values[$key] = $value;
|
||||
}
|
||||
|
||||
public function import($list)
|
||||
/**
|
||||
* Импорт значений
|
||||
* @param array $list список значений
|
||||
*/
|
||||
public function import($list): void
|
||||
{
|
||||
$this->values = array_merge($this->values, $list);
|
||||
}
|
||||
|
||||
public function __set($key, $value)
|
||||
public function __set($key, $value): void
|
||||
{
|
||||
$this->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Выполнение шаблона
|
||||
* @return string
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
$result = $this->values;
|
||||
return self::getTemplateContent ($this->document, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение содержимого шаблона
|
||||
* @param string $document шаблон
|
||||
* @param array $result результат
|
||||
* @return string содержимое шаблона
|
||||
*/
|
||||
static function getTemplateContent(string $document, $result): string
|
||||
{
|
||||
ob_start ();
|
||||
|
|
|
|||
|
|
@ -13,11 +13,22 @@ class Top extends Composite
|
|||
public $require = array();
|
||||
public $deps = array();
|
||||
|
||||
/**
|
||||
* Заголовок страницы
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return implode(" - ", array_filter($this->doTree('_title', false), [$this, 'isNotNull']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Идентификатор
|
||||
*
|
||||
* @param string $pref
|
||||
* @return string
|
||||
*/
|
||||
function getId($pref)
|
||||
{
|
||||
$this->mid++;
|
||||
|
|
@ -97,7 +108,7 @@ class Top extends Composite
|
|||
/**
|
||||
* Массив имен файлов скриптов
|
||||
*
|
||||
* return array
|
||||
* @return array
|
||||
*/
|
||||
public function getScripts()
|
||||
{
|
||||
|
|
@ -114,6 +125,11 @@ class Top extends Composite
|
|||
return implode("\n", $this->doTree('_scriptstring'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Строка со скриптом
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getScriptStartup()
|
||||
{
|
||||
return implode("\n", $this->doTree('_startup'));
|
||||
|
|
@ -122,7 +138,7 @@ class Top extends Composite
|
|||
/**
|
||||
* Массив имен файлов стилей
|
||||
*
|
||||
* return array
|
||||
* @return array
|
||||
*/
|
||||
public function getStyleSheet()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class View extends \stdClass
|
|||
* @param string $section переменная шаблона
|
||||
* @param View|string $view вложенный шаблон
|
||||
*/
|
||||
public function setView($section, $view)
|
||||
public function setView($section, $view): void
|
||||
{
|
||||
$this->_section [$section] = $view;
|
||||
if (is_object($view)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue