Compare commits

...

10 Commits

9 changed files with 120 additions and 77 deletions

View File

@ -305,7 +305,7 @@
if($this->height<=1)
echo ($this->height*100).'%;"></div>';
else
echo $this->width.'px;"></div>';
echo $this->height.'px;"></div>';
echo '<script type="text/javascript">

View File

@ -1,3 +0,0 @@
[Project]
Manager=KDevGenericManager
Name=phptools

View File

@ -2,43 +2,44 @@
function include_jquery()
{
echo '<script src="3rdpty/jquery-3.7.0.min.js"></script>';
echo '<script src="cm/3rdpty/jquery-3.7.0.min.js"></script>';
}
function include_font_awesome()
{
echo '<link rel="stylesheet" href="3rdpty/fontawesome-free-6.4.0-web/css/fontawesome.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/fontawesome-free-6.4.0-web/css/fontawesome.min.css">';
}
function include_bootstrap()
{
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap.rtl.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-grid.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-grid.rtl.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-reboot.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-reboot.rtl.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-utilities.min.css">';
echo '<link rel="stylesheet" href="3rdpty/bootstrap-5.3.0-dist/css/bootstrap-utilities.rtl.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap.rtl.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-grid.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-grid.rtl.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-reboot.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-reboot.rtl.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-utilities.min.css">';
echo '<link rel="stylesheet" href="cm/3rdpty/bootstrap-5.3.0-dist/css/bootstrap-utilities.rtl.min.css">';
echo '<link rel="stylesheet" href="3rdpty/startbootstrap-sb-admin-2-gh-pages/css/sb-admin-2.min.css">';
echo '<script src="3rdpty/startbootstrap-sb-admin-2-gh-pages/js/sb-admin-2.min.js"></script>';
echo '<link rel="stylesheet" href="cm/3rdpty/startbootstrap-sb-admin-2-gh-pages/css/sb-admin-2.min.css">';
echo '<script src="cm/3rdpty/startbootstrap-sb-admin-2-gh-pages/js/sb-admin-2.min.js"></script>';
echo '<script src="3rdpty/bootstrap-5.3.0-dist/js/bootstrap.min.js"></script>';
echo '<script src="3rdpty/bootstrap-5.3.0-dist/js/bootstrap.bundle.min.js"></script>';
echo '<script src="cm/3rdpty/bootstrap-5.3.0-dist/js/bootstrap.min.js"></script>';
echo '<script src="cm/3rdpty/bootstrap-5.3.0-dist/js/bootstrap.bundle.min.js"></script>';
}
function include_echarts()
{
echo '<script src="chart/echarts.min.js"></script>';
echo '<script src="cm/chart/echarts.min.js"></script>';
}
function echo_html_header($title)
{
echo '<html>
echo '<!DOCTYPE html>
<html lang="zh-CN">
<head>
<title>'.$title.'</title>
<meta charset="utf-8">
<title>'.$title.'</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0, width=device-width" />';
@ -182,4 +183,23 @@
{
echo get_button_link($text,$style,$link);
}
function get_by_array($array,$key)
{
if(in_array($key,$array))
{
echo 'find '.$key.' in array';
return $array[$key];
}
else
{
echo "can't find ".$key.' in array ';
return null;
}
}
function get_by_get($key)
{
return get_by_array($_GET,$key);
}
?>

View File

@ -22,5 +22,4 @@
exit;
}
?>

View File

@ -48,7 +48,7 @@
// $this->table_name=$tn;
// }
//
// public function get_field_list()
// public function sql_get_field_list()
// {
// if($field_array)
// return $field_array;
@ -84,7 +84,7 @@
// }
// };//class SQLConnect
function get_field_list($sql,$table_name)
function sql_get_field_list($sql,$table_name)
{
if($sql==null)return null;
@ -100,7 +100,7 @@
return $field_array;
}
function select_table()//$sql,$table_name,$field_array,$where,$order,$start,$count)
function sql_select_table()//$sql,$table_name,$field_array,$where,$order,$start,$count)
{
$sql =func_get_arg(0);
$table_name =func_get_arg(1);
@ -156,17 +156,19 @@
return null;
}
function select_table_to_array()//$sql,$table_name,$field_array,$where,$start,$count)
function sql_select_table_to_array()//$sql,$table_name,$field_array,$where,$order,$start,$count)
{
$sql =func_get_arg(0);
$table_name =func_get_arg(1);
$field_array =func_get_arg(2);
$field_array=func_get_arg(2);
if(func_num_args()>3)$where=func_get_arg(3);
if(func_num_args()>4)
if(func_num_args()>3)$where=func_get_arg(3);else $where=null;
if(func_num_args()>4)$order=func_get_arg(4);else $order=null;
if(func_num_args()>5)
{
$start=func_get_arg(4);
$count=func_get_arg(5);
$start=func_get_arg(5);
$count=func_get_arg(6);
}
else
{
@ -174,7 +176,7 @@
$count=0;
}
$sql_result=select_table($sql,$table_name,$field_array,$where,$start,$count);
$sql_result=sql_select_table($sql,$table_name,$field_array,$where,$order,$start,$count);
if(!$sql_result)return(null);
@ -401,15 +403,33 @@
return sql_get_field_term($sql,$table_name,$field,"AVG",$where);
}
function sql_get_field_distinct($sql,$table_name,$field,$where)
function sql_get_field_distinct()//$sql,$table_name,$field,$where,$start,$count)
{
if(!$sql)return null;
$sql =func_get_arg(0);
$table_name =func_get_arg(1);
$field =func_get_arg(2);
if(!$sql||!$table_name||!$field)return null;
if(func_num_args()>3)
$where=func_get_arg(3);
if($where)
$sql_string="select DISTINCT(".$field.") from ".$table_name.' WHERE '.$where.' ORDER BY '.$field;
else
$sql_string="select DISTINCT(".$field.") from ".$table_name.' ORDER BY '.$field;
if(func_num_args()>5)
{
$start=func_get_arg(4);
$count=func_get_arg(5);
if($start>0||$count>0)
{
$sql_string=$sql_string.' LIMIT '.$start.','.$count;
}
}
$sql_result=$sql->query($sql_string);
if(!$sql_result)

View File

@ -2,15 +2,29 @@
function create_pagination($number,$active,$link)
{
if($active>10)
{
$start=$active-10;
if($start<0)$start=0;
}
else
$start=0;
if($start+20>$number)
$end=$number;
else
$end=$start+20;
echo '<ul class="pagination">';
for($i=0;$i<$number;$i++)
for($i=$start;$i<$end;$i++)
{
if($i==$active)
echo '<li class="active"><a href="'.$link.$i.'">'.($i+1).'</a></li>';
echo '<li class="page-item active"><a class="page-link" href="'.$link.$i.'">'.($i+1).'</a></li>';
else
echo '<li><a href="'.$link.$i.'">'.($i+1).'</a></li>';
echo '<li class="page-item"><a class="page-link" href="'.$link.$i.'">'.($i+1).'</a></li>';
}
echo '</u>';
echo '</ul>';
}

View File

@ -1,8 +1,8 @@
<?php
require_once "tools.php";
require_once "tools_session.php";
require_once "tools_json.php";
require_once "cm/tools.php";
require_once "cm/tools_session.php";
require_once "cm/tools_json.php";
class UISideBar
{
@ -47,7 +47,7 @@
if($this->bar_list==null)return;
echo '<div class="row" style="margin-left: 0px; margin-right: 0px;">';
echo '<div class="col-xs-'.$this->sidebar_width.' bs-docs-sidebar" style="padding-top: 15px;">
echo '<div class="col-xxl-'.$this->sidebar_width.' bs-docs-sidebar" style="padding-top: 15px;">
<div class="list-group bs-docs-sidenav affix-top">';
foreach($this->bar_list as $code=>$obj)
@ -60,7 +60,7 @@
echo '</div>
</div>
<div div class="col-xs-'.(12-$this->sidebar_width).'" style="padding-left: 0px;">';
<div div class="col-xxl-'.(12-$this->sidebar_width).'" style="padding-left: 0px;">';
}
public function end()
@ -69,3 +69,4 @@
</div>';
}
};//class UISideBar
?>

View File

@ -20,26 +20,9 @@
class UITable
{
protected $title_cols=null;
private $heading=null;
private $heading_style="default";
private $body=null;
private $thead_style=null;
private $table_style="striped";
public function set_heading($h)
{
$this->heading=$h;
}
public function set_heading_style($hs)
{
$this->heading_style=$hs;
}
public function set_body_text($bt)
{
$this->body=$bt;
}
public function set_title_col_text($f)
{
foreach($f as $tt)
@ -51,6 +34,11 @@
$this->title_cols=$f;
}
public function set_title_thead_style($s)
{
$this->thead_style=$s;
}
public function set_table_style($ts)
{
$this->table_style=$ts;
@ -58,14 +46,6 @@
public function start()
{
echo '<div class="panel panel-'.$this->heading_style.'" style="margin-bottom: 0px;">';
if($this->heading!=null)
echo '<div class="panel-heading">'.$this->heading.'</div>';
if($this->body!=null)
echo '<div class="panel-body"><p style="margin-bottom: 0px;">'.$this->body.'</p></div>';
if($this->table_style)
echo '<table class="table table-responsive table-'.$this->table_style.'">';
else
@ -73,6 +53,9 @@
if($this->title_cols!=null)
{
if($this->thead_style!=null)
echo '<thead class="table-'.$this->thead_style.'">';
echo '<tr>';
foreach($this->title_cols as $field)
{
@ -92,6 +75,9 @@
echo '</th>';
}
echo '</tr>';
if($this->thead_style!=null)
echo '</thead>';
}
}
@ -101,8 +87,15 @@
public function start_col (){echo '<td>';}
public function end_col (){echo '</td>';}
public function skip_col (){echo '<td/>';}
public function echo_col ($text){echo '<td>'.$text.'</td>';}
public function echo_multi_col($text_list)
{
foreach($text_list as $text)
echo '<td>'.$text.'</td>';
}
public function echo_row ($text_list)
{
start_row();
@ -115,8 +108,7 @@
public function end()
{
echo '</table>
</div>';
echo '</table>';
}
};//class UITable
@ -140,13 +132,13 @@
if($field_list==null)
{
$field_list=get_field_list($sql,$sql_table_name);
$field_list=sql_get_field_list($sql,$sql_table_name);
parent::set_title_col($field_list);
$this->sql_fields=$field_list;
$this->sql_result=select_table_to_array($sql,$sql_table_name,null,$where,$start,$count);
$this->sql_result=sql_select_table_to_array($sql,$sql_table_name,null,$where,$start,$count);
}
else
{
@ -154,7 +146,7 @@
$this->sql_fields=$field_list;
$this->sql_result=select_table_to_array($sql,$sql_table_name,$field_list,$where,$start,$count);
$this->sql_result=sql_select_table_to_array($sql,$sql_table_name,$field_list,$where,$start,$count);
}
}