From 5127bcec3a162323c40385ecf5c004edcdbdac89 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 2 Nov 2022 08:42:00 +0800 Subject: [PATCH] * Add comment of zin. --- module/program/ui/browse.html.php | 5 +- zin/block.class.php | 60 ++++++++++++++-- zin/wg/actionbar/v1.php | 2 +- zin/wg/button/v1.php | 8 ++- zin/wg/dtable/v1.php | 114 ++++++++++++++++++++++++++++-- 5 files changed, 173 insertions(+), 16 deletions(-) diff --git a/module/program/ui/browse.html.php b/module/program/ui/browse.html.php index ffb7e48ec3..c4e875726a 100644 --- a/module/program/ui/browse.html.php +++ b/module/program/ui/browse.html.php @@ -24,9 +24,10 @@ if(common::hasPriv('project', 'create')) $actionbar->append($button); } -if(isset($lang->pageActions)) +if(common::hasPriv('program', 'create')) { - $actionbar->append($lang->pageActions); + $button = html::a($this->createLink('program', 'create'), " " . $this->lang->program->create, '', "class='btn btn-primary create-program-btn'"); + $actionbar->append($button); } $menu = block('h'); diff --git a/zin/block.class.php b/zin/block.class.php index 5db0c3eae0..7db519b2a1 100644 --- a/zin/block.class.php +++ b/zin/block.class.php @@ -1,11 +1,39 @@ + * @package block + * @version $Id + * @link https://www.zentao.net + */ class block { - public $children = array(); + /** + * Menu list. + * + * @var array + * @access public + */ + public $menus = array(); + /** + * Block type. + * + * @var string vertical(v)|horizon(h) + * @access private + */ private $type = 'v'; - public function __contruct($type) + /** + * Construct function, init block data. + * + * @param string $type + * @access public + * @return void + */ + public function __construct($type) { global $app, $config, $lang; @@ -15,20 +43,38 @@ class block $this->type = $type; } + /** + * Set menus. + * + * @param string $attr + * @param object $value + * @access public + * @return void + */ public function __set($attr, $value) { - $this->children[$attr] = $value; + $this->menus[$attr] = $value; } + /** + * Print menu. + * + * @access public + * @return void + */ public function x() { - foreach($this->children as $key => $child) - { - echo $child->toString(); - } + foreach($this->menus as $key => $menu) echo $menu->toString(); } } +/** + * Get block object. + * + * @param string $type vertical(v)|horizon(h) + * @access public + * @return object + */ function block($type = 'v') { return new block($type); diff --git a/zin/wg/actionbar/v1.php b/zin/wg/actionbar/v1.php index 092092c052..cf7061999c 100644 --- a/zin/wg/actionbar/v1.php +++ b/zin/wg/actionbar/v1.php @@ -32,7 +32,7 @@ class actionbar extends wg /** * Set action data. * - * @param object $item + * @param object|string $item * @access public * @return void */ diff --git a/zin/wg/button/v1.php b/zin/wg/button/v1.php index 26925d9f50..2657b76e55 100644 --- a/zin/wg/button/v1.php +++ b/zin/wg/button/v1.php @@ -43,7 +43,7 @@ class button extends wg public $newline = true; /** - * Construct function, init tab data. + * Construct function, init button data. * * @param string $text * @access public @@ -107,6 +107,12 @@ class button extends wg return $this; } + /** + * Get button html. + * + * @access public + * @return string + */ public function toString() { return html::a($this->link, $this->text, $this->target, $this->misc . $this->toHx(), $this->newline); diff --git a/zin/wg/dtable/v1.php b/zin/wg/dtable/v1.php index 3814b543de..505ea66939 100644 --- a/zin/wg/dtable/v1.php +++ b/zin/wg/dtable/v1.php @@ -1,6 +1,23 @@ + * @package dtable + * @version $Id + * @link https://www.zentao.net + */ class column extends wg { + /** + * Construct function, init table data. + * + * @param string $name + * @param string $title + * @access public + * @return void + */ public function __construct($name, $title) { parent::__construct(); @@ -8,6 +25,13 @@ class column extends wg $this->title = $title; } + /** + * Set column width. + * + * @param int $width + * @access public + * @return object + */ public function width($width) { $this->width = $width; @@ -27,12 +51,26 @@ class column extends wg return $this; } - public function flex($width) + /** + * Set flex attribute of column. + * + * @param int $growValue + * @access public + * @return object + */ + public function flex($growValue) { - $this->flex = $width; + $this->flex = (int)$growValue; return $this; } + /** + * Set fixed attribute of column. + * + * @param string $position left|right + * @access public + * @return object + */ public function fixed($position) { $this->fixed = $position; @@ -44,7 +82,7 @@ class column extends wg * * @param string|bool $type up|down|true|false * @access public - * @return void + * @return object */ public function sortType($type) { @@ -52,6 +90,12 @@ class column extends wg return $this; } + /** + * Set checkbox. + * + * @access public + * @return void + */ public function checkbox() { $this->checkbox = 1; @@ -61,16 +105,53 @@ class column extends wg class dtable { + /** + * Columns. + * + * @var array + * @access public + */ public $cols = array(); + /** + * Search. + * + * @var string + * @access public + */ public $search = ''; + /** + * Footer. + * + * @var string + * @access public + */ public $footer = ''; + /** + * Form. + * + * @var string + * @access public + */ public $form = ''; + /** + * System config. + * + * @var object + * @access public + */ public $config; + /** + * Construct function, init dtable data. + * + * @param string $text + * @access public + * @return void + */ public function __construct($text = '') { global $config; @@ -79,6 +160,14 @@ class dtable $this->text = $text; } + /** + * Get column object. + * + * @param string $name + * @param string $title + * @access public + * @return object + */ public function col($name, $title) { $col = new column($name, $title); @@ -105,11 +194,26 @@ class dtable } } + /** + * Set table data. + * + * @param array $data + * @access public + * @return void + */ public function data($data) { $this->data = $data; } + /** + * Set search html. + * + * @param string $status + * @param string $module + * @access public + * @return object + */ public function search($status, $module) { $this->search = '
'; @@ -142,7 +246,7 @@ class dtable } /** - * Set form. + * Set form html. * * @param string $formID * @param string $class @@ -156,7 +260,7 @@ class dtable } /** - * Print datatable. + * Get datatable. * * @access public * @return string