Common Library for Cool projects
Common Library for Cool projects., (*1)
about Form\FormHelper, (*2)
``` // This class is compatible with these templates // 'text' => '', // 'select' => [''],, (*3)
/* * * return example Array ( [0] => Array ( [0] => text [1] => Array ( [0] => sitename [1] => hero ) ) [1] => Array ( [0] => select [1] => Array ( [0] => Array ( [0] => language ) [1] => Array ( [0] => Array ( [0] => selected="selected" [1] => zh_CN [2] => 简体中文 ) [1] => Array ( [0] => [1] => en_US [2] => 英语 ) ) [2] => Array ( ) ) ) ), (*4)
*/, (*5)
- about Form\FormCore
$cfg = [ 'formOpen' => ', (*6)
', ];, (*7)
$form = new FormCore($cfg); $form->addMultiData(['formOpen', ['', 'post']]); $form->addData(['text', ['fname', 'carl']]); $form->addData(['formEnd', []]); echo $form->render();, (*8)
- about Category\CategoryHelper
//====================Test code ================================, (*9)
header("content-type:text/html;charset=utf-8"); $categories = array( array('id'=>1,'name'=>'电脑','pid'=>0), array('id'=>2,'name'=>'手机','pid'=>0), array('id'=>3,'name'=>'笔记本','pid'=>1), array('id'=>4,'name'=>'台式机','pid'=>1), array('id'=>5,'name'=>'智能机','pid'=>2), array('id'=>6,'name'=>'功能机','pid'=>2), array('id'=>7,'name'=>'超级本','pid'=>3), array('id'=>8,'name'=>'游戏本','pid'=>3), );, (*10)
//$cate = new CategoryHelper(); $cate = CategoryHelper::render($categories); $cate = CategoryHelper::format($categories);, (*11)
- about Http\CurlHelper
//============ Test ================= //$curl = new curlHelper(); //$url = 'http://a.com/dfdsf/?dxid=dsl'; //$curl->curlGet($url,['name'=>'carl']);, (*12)
- about Pagination\Pagination
//============ Generate normal pagination ================= $p = new Pagination(); $page = isset($_GET['page']) ? intval($_GET['page']) : 8; $page = $page > 0 ? $page : 8; $p->init($page, 123); $p->setTotalNum(1230);, (*13)
// echo css echo ' ';, (*14)
echo $p->view();, (*15)
// Generate js pagination. (You can add js event to loop), (*16)
$p = new Pagination(); $page = isset($_GET['page']) ? intval($_GET['page']) : 7; $page = $page > 0 ? $page : 7; $p->init($page, 123);, (*17)
$template = [ 'pageWrapper' => ', (*18)
', 'firstPage' => [ ', (*19)
$p->setTemplate($template); $p->setTotalNum(12050); echo $p->view();, (*20)
- about Helpers\CoolArray ```php $data = [ "dataShow" => [ "conf"=>[ "key"=>"type", "code"=>[ "order-data"=>"TA", "change-data"=>"DATA.CUSTOMER_CHANGE_DATA", "turn-data"=>"CUSTOMER.CRM_TURN_REGION", "leads-data"=>"TASK.CRM_LEADS_QUERY", "tag-data"=>"CONFIG.OS_CATEGORY", "user-data"=>"CONFIG.OS_CATEGORY", "see-phone"=>1, ] ], "requireParam"=>"type", "paramCont"=>["order-data", "tag-data", "user-data", 'see-phone'] ], ]; $structure = [ "dataShow" => [ "conf"=>[ "key"=>"type", "code"=>[ "order-data"=>"fdgfd", "change-data"=>"DATA.CUSTOMER_CHANGE_DATA", "turn-data"=>"CUSTOMER.CRM_TURN_REGION", "leads-data"=>"TASK.CRM_LEADS_QUERY", "tag-data"=>"CONFIG.OS_CATEGORY", "user-data"=>"CONFIG.OS_CATEGORY", "see-phone"=>"CONFIG.OS_CATEGORY", ] ], "requireParam"=>"type", "paramCont"=>["order-data", "change-data", "tag-data", "user-data", 'see-phone'] ], ]; $ret = CoolArray::checkStructure($data, $structure); var_dump($ret);