MainController.php 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027
  1. <?php
  2. /**
  3. * MainController
  4. * Feel free to delete the methods and replace them with your own code.
  5. *
  6. * @author darkredz
  7. */
  8. class MainController extends DooController{
  9. private $column;
  10. private $comart;
  11. function __construct() {
  12. include './protected/config/index.conf.php';
  13. $this->column=$column;
  14. Doo::loadModel('Article');
  15. $article=new Article();
  16. $cid=$this->column['COMPANY'];
  17. $this->comart=$article->getArticleByCid($cid,4);
  18. }
  19. function index() {
  20. Doo::loadModel('Column');
  21. Doo::loadModel('Product');
  22. $article=new Article();
  23. $product=new Product();
  24. $column=new Column();
  25. $cid=$this->column['SOFTAPP'].",".$this->column['WEBAPP'];
  26. $data['WEBAPP']=$this->column['WEBAPP'];
  27. $col=$column->getColumnByIdList($cid);
  28. //foreach ($col as $key=>$value){
  29. $pro=$product->getProductByCid($col[0]['cid']);
  30. $col[0]['product']=$pro;
  31. //}
  32. $cid=$this->column['TRAINC'];
  33. $train=$article->getArticleByTrain(2);
  34. $end=$doing=$apply=array();
  35. foreach ($train as $key=>$value){
  36. $type=getTrainTimeByStatus($value['enroll_time']);
  37. $date=explode(":", $value['enroll_time']);
  38. if($type=="end"){
  39. $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  40. array_push($end, $train[$key]);
  41. }elseif ($type=="doing"){
  42. $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  43. array_push($doing, $train[$key]);
  44. }elseif ($type=="apply"){
  45. $time = strtotime($date[0]) - 60*60*24;
  46. $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  47. array_push($apply, $train[$key]);
  48. }
  49. }
  50. $ta=$apply+$doing+$end;
  51. //print_r($ta);die;
  52. //$type=="apply";
  53. //$article->find ( array ('desc' => 'time', 'limit'=>4 , 'where' => 'cid=4 and ', 'asArray' => TRUE ) );
  54. //$art=$article->getArticleByCid($cid,4);
  55. $art=array_slice($ta,0,4);
  56. foreach ($art as $key=>$value){
  57. $art[$key]['timeStuts']=getTrainTime2($value['enroll_time']);
  58. $art[$key]['timeStuts3']=getTrainTime3($value['enroll_time']);
  59. $art[$key]['Stuts']=strlen($art[$key]['timeStuts']);
  60. }
  61. $list1=$article->getArticleByCid2($this->column['COMPANY'],5);
  62. foreach ($list1 as $key=>$value){
  63. $list1[$key]['title']=$this->cut_str($value['title'], 45);
  64. }
  65. $list2=$article->getArticleByCid($this->column['INDUSTRY'],5);
  66. foreach ($list2 as $key=>$value){
  67. $list2[$key]['title']=$this->cut_str($value['title'], 45);
  68. }
  69. Doo::loadModel('Product');
  70. $product=new Product();
  71. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  72. $data['article']=$art;
  73. $data['comart']=$this->comart;
  74. $data['column']=$col;
  75. $data['map']='index';
  76. $data['companyNews']=$list1;
  77. $data['industryNews']=$list2;
  78. $this->render ( "/index3", $data );
  79. }
  80. function softDown2(){
  81. Doo::loadModel('Product');
  82. Doo::loadModel('Down');
  83. $down=new Down();
  84. $product=new Product();
  85. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  86. $html="";
  87. foreach ($data['product'] as $key=>$value){
  88. $data['product'][$key]['down']=array();
  89. if(!empty($value['did']))
  90. $data['product'][$key]['down']=$down->getDownByIdList($value['did']);
  91. foreach ($data['product'][$key]['down'] as $keys=>$values){
  92. $t=explode("{b}", $values['down_url']);
  93. $i=2;
  94. foreach ($t as $k=>$v){
  95. if($i==2)
  96. $html.='<a href="'.$v.'">点击下载</a>';
  97. // elseif($i==1)
  98. // $html.='<a href="'.$v.'">联通线路</a>';
  99. $i--;
  100. }
  101. $data['product'][$key]['down'][$keys]['html']=$html;
  102. $i=2;$html="";
  103. }
  104. }
  105. $data['comart']=$this->comart;
  106. $data['map']='softDown';
  107. $this->render ( "/softDown2", $data );
  108. }
  109. function softDown(){
  110. Doo::loadModel('Product');
  111. $product=new Product();
  112. $data['product']=$product->getProductByCidAll($this->column['SOFTAPP']);
  113. $data['comart']=$this->comart;
  114. $data['map']='softDown';
  115. $this->render ( "/softDown", $data );
  116. }
  117. function ajaxSoftDown(){
  118. Doo::loadModel('Down');
  119. Doo::loadModel('Product');
  120. Doo::loadModel('Animation');
  121. $animation=new Animation();
  122. $product=new Product();
  123. $down=new Down();
  124. $did=$this->get_args('did');
  125. $pid=$this->get_args('pid');
  126. if(!empty($did))
  127. $do['dot']=$down->getDownByIdList($did);
  128. $info=$product->getProductById($pid);
  129. $MyAnimation=array();
  130. if(!empty($info[0]['anid']))
  131. $MyAnimation=$animation->getAnimationByIdList($info[0]['anid']);
  132. $belongAnimation=$animation->getAnimationByBelong();
  133. $uc='<div class="softVideo">
  134. <div class="videoItem">';
  135. if (empty($MyAnimation) ){
  136. $uc.='<span class="tips">该软件无专属教程,您可观看通用教程</span>';
  137. }else{
  138. $uc.='<h1>专属教程</h1>
  139. <ul class="clearfix">';
  140. foreach ($MyAnimation as $key=>$value){
  141. $uc.='<li>
  142. <img src="'.$value['img_url'].'">
  143. <h3>'.$value['title'].'</h3>
  144. <div class="videoCon">
  145. <span class="playBtn" data-toggle="modal" href="#myModal'.$value['aid'].'" data-keyboard="false" data-backdrop="ture"><b></b>播放</span>
  146. <a target="blank" href="'.$value['down_url'].'" ><span class="downBtn"><b></b>下载</span></a>
  147. </div>
  148. </li>';
  149. }
  150. $uc.='</ul>';
  151. }
  152. $uc.='</div>
  153. <div class="videoItem">
  154. <h1>通用教程</h1>
  155. <ul class="clearfix">';
  156. foreach ($belongAnimation as $key=>$value){
  157. $uc.='<li>
  158. <img src="'.$value['img_url'].'">
  159. <h3>'.$value['title'].'</h3>
  160. <div class="videoCon">
  161. <span class="playBtn" data-toggle="modal" href="#myModal'.$value['aid'].'" data-keyboard="false" data-backdrop="ture"><b></b>播放</span>
  162. <a target="blank" href="'.$value['down_url'].'"> <span class="downBtn"><b></b>下载</span> </a>
  163. </div>
  164. </li>';
  165. }
  166. $uc.='</ul>
  167. </div>
  168. <div class="bottomSpace"></div>
  169. </div>';
  170. $html='<div class="dSoftInof">
  171. <div class="productTab clearfix">
  172. <div class="title fL"><img width="32" src="'.$info[0]['logo'].'"><b>'.$info[0]['title'].'</b></div>
  173. <ul>
  174. <li class="now" id="a" onclick="changeProduct(\'info\')" title="查看版本功能更新">版本更新</li>
  175. <li id="c" onclick="changeProduct(\'edition\')" title="浏览软件简介" class="">软件介绍</li>
  176. <li id="d" onclick="changeProduct(\'animation\')" title="观看软件动画教程" class="">动画教程 </li>
  177. </ul>
  178. </div>
  179. <div class="contentItem" id="info" style="display: block;">
  180. '.$info[0]['edition'].'
  181. </div>
  182. <div class="contentItem" id="edition" style="display: none;">
  183. '.$info[0]['content'].'
  184. </div>
  185. <div class="contentItem" id="animation" style="display: none;">
  186. '.$uc.'
  187. </div>
  188. </div>';
  189. if($info[0]['p_type']!=2)
  190. $do['info']=$html;
  191. else
  192. $do['info']="";
  193. $show=json_encode($do);
  194. echo $show;
  195. }
  196. function product(){
  197. $pid=$this->params['pid'];
  198. $tab = $this->get_args ( 'tab' ) ? $this->get_args ( 'tab' ) : 'down';
  199. $pid=is_numeric($pid)?$pid:0;
  200. Doo::loadModel('Product');
  201. Doo::loadModel('Down');
  202. Doo::loadModel('DownVersion');
  203. $down=new Down();
  204. $product=new Product();
  205. $downversion=new DownVersion();
  206. Doo::loadModel('Animation');
  207. $animation=new Animation();
  208. Doo::loadModel( 'Course' );
  209. $course = new Course();
  210. $data['product']=$product->getProductByCid($this->column['SOFTAPP']);
  211. if (empty($pid))
  212. $pid=$data['product'][0]['pid'];
  213. //获取下载内容
  214. $data['productInfo']=$product->getProductById($pid);
  215. if(isset($data['productInfo'][0]['isstartup']) && $data['productInfo'][0]['isstartup'] == 1) {
  216. Doo::loadModel('Startup');
  217. $startup = new Startup();
  218. $data['down_url'] = $startup->getDownUrlById();
  219. }
  220. if(empty($data['productInfo'][0]['did']))
  221. $data['productInfo'][0]['did']=0;
  222. $do=$down->getDownByIdList($data['productInfo'][0]['did']);
  223. foreach ($do as $key=>$value){
  224. $url=explode("{b}", $value['down_url']);
  225. $do[$key]['down_url']=$url;
  226. $down_version_msg = $downversion->getVersionByDidAnd2($value['did']);
  227. $do[$key]['version_msg'] = !empty($down_version_msg) ? $down_version_msg['version_msg'] : '';
  228. }
  229. $data['productInfo'][0]['down']=$do;
  230. //获得教程
  231. $courseList=$course->getCourseAllLikePid($pid);
  232. $data['courseList']=$courseList;
  233. // $data['MyAnimation']=array();
  234. // if(!empty($data['productInfo'][0]['anid']))
  235. // $data['MyAnimation']=$animation->getAnimationByIdList($data['productInfo'][0]['anid']);
  236. //
  237. // $data['belongAnimation']=$animation->getAnimationByBelong();
  238. $data['tab']=$tab;
  239. $data['comart']=$this->comart;
  240. $data['map']='product';
  241. $data['title']=$data['productInfo'][0]['title'];
  242. $this->render ( "/product", $data );
  243. }
  244. /*
  245. *教程
  246. */
  247. function course(){
  248. $idKey=isset($this->params ['idKey'])?$this->params['idKey']:'';
  249. $p = $this->get_args ( 'p' ) && is_numeric ( $this->get_args ( 'p' ) ) ? $this->get_args ( 'p' ) : '';
  250. Doo::loadClass ( 'XDeode' );
  251. $XDeode = new XDeode ( 5 );
  252. $id = $XDeode->decode ( $idKey );
  253. if (! is_numeric ( $id ))
  254. die ( 'illegal request' );
  255. Doo::loadModel( 'Course' );
  256. $course = new Course();
  257. Doo::loadModel('Animation');
  258. $animation=new Animation();
  259. $courseDetail=$course->getCourseById($id);
  260. $courseDetail['videoHtml']='';
  261. foreach ($courseDetail['animationList'] as $key=>$value){
  262. /* preg_match_all("/<video(.*)src=\"([^\"]+)\"[^>]+>/isU",$courseDetail['animationList'][$key]['url'],$matches);
  263. $courseDetail['animationList'][$key]['videoSrc']=$matches[2][0];*/
  264. if (empty($p)){
  265. $courseDetail['animationList'][0]['url']=str_replace("<video"
  266. ,"<video id='player' class='video-js vjs-default-skin vjs-big-play-centered vjs-fluid'
  267. poster='".$value['img_url']."'
  268. ",$value['url']);
  269. $courseDetail['videoHtml']=$courseDetail['animationList'][0]['url'];
  270. $courseDetail['videoDown']=$courseDetail['animationList'][0]['down_url'];
  271. $courseDetail['videoTitle']=$courseDetail['animationList'][0]['title'];
  272. break;
  273. }else{
  274. if($p==$value['aid']){
  275. $courseDetail['animationList'][$key]['url']=str_replace("<video"
  276. ,"<video id='player' class='video-js vjs-default-skin vjs-big-play-centered vjs-fluid'
  277. poster='".$value['img_url']."'
  278. ",$value['url']);
  279. $courseDetail['videoHtml']=$courseDetail['animationList'][$key]['url'];
  280. $courseDetail['videoDown']=$courseDetail['animationList'][$key]['down_url'];
  281. $courseDetail['videoTitle']=$courseDetail['animationList'][$key]['title'];
  282. break;
  283. }
  284. }
  285. }
  286. $data['title']=$courseDetail['videoTitle'];
  287. $courseDetail['animationCount']=count($courseDetail['animationList']);
  288. $data['courseDetail']=$courseDetail;
  289. $data['map']='product';
  290. $this->render ( "/coursePlay", $data );
  291. }
  292. function aboutUs(){
  293. $k=isset($this->params ['k'])?$this->params['k']:'';
  294. $data['comart']=$this->comart;
  295. $data['map']='aboutUs';
  296. if (empty($k)){
  297. $this->render ( "/aboutUsAbout", $data );
  298. }else{
  299. Doo::loadModel('Article');
  300. $article=new Article();
  301. //$s=strtotime(date('Y')."-01-01");
  302. $s=strtotime("2015-01-01");
  303. $list=$article->find(array ( 'where' => 'cid= 7 and time>='.$s,'desc'=>'time','asArray' => TRUE ));
  304. foreach ($list as $key=>$value){
  305. $list[$key]['year']=date('Y',$value['time']);
  306. $list[$key]['month']=date('m',$value['time']);
  307. if(empty($value['thum']))
  308. $list[$key]['thum']='/global/img/2.png';
  309. }
  310. $data['list']=$list;
  311. $data['year']=date('Y');
  312. $this->render ( "/".$k, $data );
  313. }
  314. }
  315. function contact(){
  316. $data['comart']=$this->comart;
  317. $data['map']='contact';
  318. $data['iscontact'] = 1;
  319. $this->render ( "/contact", $data );
  320. }
  321. function contact4(){
  322. $data['comart']=$this->comart;
  323. $data['map']='contact';
  324. $data['iscontact'] = 1;
  325. Doo::loadModel('Contact');
  326. Doo::loadModel('ContactProvince');
  327. $contact = new Contact();
  328. $contactProvince = new ContactProvince();
  329. $area = array('华东', '华南', '华中', '华北', '西北', '西南', '东北');
  330. $list = array();
  331. foreach ($area as $k => $v) {
  332. $provinceList = $contactProvince->getListByArea($k);
  333. foreach ($provinceList as $pk => $pv) {
  334. $staffList = $contact->getRowByProvince($pv['id']);
  335. $provinceList[$pk]['staffList'] = $staffList;
  336. array_push($list, $provinceList[$pk]);
  337. }
  338. }
  339. $data['list'] = $list;
  340. $this->render ( "/contact4", $data );
  341. }
  342. function contact2(){
  343. $data['iscontact'] = 1;
  344. $this->render ( "/contact2", $data );
  345. }
  346. function contact3(){
  347. $data['iscontact'] = 1;
  348. Doo::loadModel('Contact');
  349. Doo::loadModel('ContactProvince');
  350. $contact = new Contact();
  351. $contactProvince = new ContactProvince();
  352. $area = array('华东', '华南', '华中', '华北', '西北', '西南', '东北');
  353. $data['area'] = $area;
  354. $list = array();
  355. foreach ($area as $k => $v) {
  356. $provinceList = $contactProvince->getListByArea($k);
  357. foreach ($provinceList as $pk => $pv) {
  358. $staffList = $contact->getRowByProvince($pv['id']);
  359. $provinceList[$pk]['staffList'] = $staffList;
  360. }
  361. $list[$k]['provinceList'] = $provinceList;
  362. }
  363. $data['list'] = $list;
  364. $this->render ( "/contact3", $data );
  365. }
  366. function train(){
  367. // $article=new Article();
  368. // $train=$article->getArticleByTrain(2);
  369. // $end=$doing=$apply=array();
  370. //
  371. // foreach ($train as $key=>$value){
  372. // $type=getTrainTimeByStatus($value['enroll_time']);
  373. // $date=explode(":", $value['enroll_time']);
  374. //
  375. // if($type=="end"){
  376. //
  377. // $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  378. // array_push($end, $train[$key]);
  379. // }elseif ($type=="doing"){
  380. //
  381. // $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  382. // array_push($doing, $train[$key]);
  383. // }elseif ($type=="apply"){
  384. //
  385. // $time = strtotime($date[0]) - 60*60*24;
  386. // $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  387. // array_push($apply, $train[$key]);
  388. // }
  389. // }
  390. //
  391. // $train=$article->getArticleByTrain(1);
  392. // $end1=$doing1=$apply1=array();
  393. //
  394. // foreach ($train as $key=>$value){
  395. // $type=getTrainTimeByStatus($value['enroll_time']);
  396. // $date=explode(":", $value['enroll_time']);
  397. //
  398. // if($type=="end"){
  399. //
  400. // $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  401. // array_push($end1, $train[$key]);
  402. // }elseif ($type=="doing"){
  403. //
  404. // $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  405. // array_push($doing1, $train[$key]);
  406. // }elseif ($type=="apply"){
  407. //
  408. // $time = strtotime($date[0]) - 60*60*24;
  409. // $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  410. // array_push($apply1, $train[$key]);
  411. // }
  412. // }
  413. //
  414. // $data['end1']=$end1;
  415. // $data['doing1']=$doing1;
  416. // $data['apply1']=$apply1;
  417. //
  418. // $data['end']=$end;
  419. // $data['doing']=$doing;
  420. // $data['apply']=$apply;
  421. // $data['comart']=$this->comart;
  422. // $data['map']='trainI';
  423. // $this->render ( "/train2", $data );
  424. //新培训班页
  425. $article=new Article();
  426. $trainType = isset($_GET['trainType']) && is_numeric($_GET['trainType']) ? $_GET['trainType'] : '';
  427. //列出11个地区培训班数量
  428. $areaArr = array('广东', '山东', '内蒙古', '广西', '重庆', '新疆', '江西', '安徽', '四川', '浙江', '甘肃', '湖南', '贵州');
  429. $area = isset($_GET['area']) && in_array($_GET['area'], $areaArr) ? $_GET['area'] : '';
  430. $train= !isset($_GET['trainType']) && !isset($_GET['area']) ? $article->getArticleByTrain3() : $article->getArticleByTrain2($trainType,$area);
  431. $end=$doing=$apply=$areatrainnum=array();
  432. foreach($areaArr as $k => $v){
  433. $trainnum = $article->getArticleNumByTrain2($trainType,$v);
  434. array_push($areatrainnum,$trainnum);
  435. }
  436. foreach ($train as $key=>$value){
  437. $type=getTrainTimeByStatus($value['enroll_time']);
  438. $date=explode(":", $value['enroll_time']);
  439. if($type=="end"){
  440. $train[$key]['timeStuts']="<p class='tData'>结束 ".$date[1]."</p>";
  441. array_push($end, $train[$key]);
  442. }elseif ($type=="doing"){
  443. $train[$key]['timeStuts']="<span class='tIcon'>进行中</span>";
  444. array_push($doing, $train[$key]);
  445. }elseif ($type=="apply"){
  446. $time = strtotime($date[0]) - 60*60*24;
  447. $train[$key]['timeStuts']="<span class='tIcon'>报名中</span><p class='tData'>截止".date('Y-m-d',$time)."</p>";
  448. array_push($apply, $train[$key]);
  449. }
  450. }
  451. $data['end']=$end;
  452. $data['doing']=$doing;
  453. $data['apply']=$apply;
  454. $data['areatrainnum']=$areatrainnum;
  455. $data['area'] = $area;
  456. $data['trainType'] = $trainType;
  457. $data['comart']=$this->comart;
  458. $data['map']='trainI';
  459. $this->render ( "/train2", $data );
  460. }
  461. function trainPage(){
  462. $aid=$this->params['aid'];
  463. $aid=is_numeric($aid)?$aid:0;
  464. if(empty($aid)){
  465. return "/train";
  466. }
  467. $article=new Article();
  468. $trainPage=$article->getArticleByTrainAid($aid);
  469. $trainPage[0]['timeStuts']=getTrainTime($trainPage[0]['enroll_time']);
  470. $trainPage[0]['class']=getTrainTimeByStatus($trainPage[0]['enroll_time']);
  471. $data['trainPage']=$trainPage[0];
  472. $data['comart']=$this->comart;
  473. $data['map']='train';
  474. $this->render ( "/trainPage", $data );
  475. }
  476. function searchNews(){
  477. $kind = $this->get_args('kind') ? $this->get_args('kind') : 1;
  478. $k = $this->get_args('k') ? $this->get_args('k') : "";
  479. $onPage =$this->get_args('onPage')&&is_numeric ( $this->get_args('onPage') ) ? $this->get_args('onPage') : 1;
  480. $list=array();$next=0;$previous=0;
  481. if (!empty($k)){
  482. Doo::loadModel('Down');
  483. $down=new Down();
  484. $article=new Article();
  485. if ($onPage <= 0)
  486. $onPage = 1;
  487. $pageSize = 20;
  488. $o=$onPage;
  489. $lower = (-- $o) * $pageSize;
  490. $previous = $onPage != 0 ? $onPage - 1 : $onPage;
  491. if ($kind==2){
  492. $list=$down->getDownByAnyWhere($k);
  493. //$list=$down->find(array('where'=>'title like "%'.$k.'%" or key_number like "%'.$k.'%"','limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  494. $totalCount = $down->count(array('where'=>'title like "%'.$k.'%" or key_number like "%'.$k.'%"','limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  495. $total = intval ( $totalCount / $pageSize );
  496. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  497. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  498. foreach ($list as $key=>$value){
  499. $url=explode("{b}", $value['down_url']);
  500. $list[$key]['down_url']=$url;
  501. }
  502. }elseif($kind==3){
  503. Doo::loadModel('ArticleDao');
  504. $ArticleDao=new ArticleDao();
  505. $list=$ArticleDao->find(array('select'=>'title,aid,cid,time','where'=>'title like "%'.$k.'%" ',
  506. 'limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  507. $totalCount = $ArticleDao->count(array('where'=>'title like "%'.$k.'%" ','asArray' => TRUE));
  508. $total = intval ( $totalCount / $pageSize );
  509. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  510. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  511. }else{//or content like "%'.$k.'%"
  512. $list=$article->find(array('select'=>'title,aid,cid,time','where'=>'title like "%'.$k.'%" and ( cid=4 or cid=5 or cid=3 or cid=7)',
  513. 'limit'=>$lower.','.$pageSize ,'asArray' => TRUE));
  514. $totalCount = $article->count(array('where'=>'title like "%'.$k.'%" and ( cid=4 or cid=5 or cid=3 or cid=7)','asArray' => TRUE));
  515. $total = intval ( $totalCount / $pageSize );
  516. $totalPage = ($totalCount % $pageSize) == 0 ? $total : $total + 1;
  517. $next = $onPage == $totalPage ? $totalPage : $onPage + 1;
  518. foreach ($list as $key=>$value){
  519. if($value['cid']==4)
  520. $list[$key]['c']='公司新闻';
  521. elseif ($value['cid']==5)
  522. $list[$key]['c']='行业新闻';
  523. elseif ($value['cid']==3)
  524. $list[$key]['c']='培训教育';
  525. elseif ($value['cid']==7)
  526. $list[$key]['c']='软件更新';
  527. }
  528. }
  529. }
  530. $data['next']=$next;
  531. $data['previous']=$previous;
  532. $data['k']=$k;
  533. $data['onPage']=$onPage;
  534. $data['list']=$list;
  535. $data['kind']=$kind;
  536. $data['map']='sNews';
  537. $this->render ( "/search", $data );
  538. }
  539. function news(){
  540. $n = "";
  541. $cid=isset($this->params ['cid'])&&is_numeric($this->params['cid'])?$this->params['cid']:$this->column['COMPANY'];
  542. $aid=isset($this->params ['aid'])&&is_numeric($this->params['aid'])?$this->params['aid']:0;
  543. $on_page = isset($this->params ['page'])&&is_numeric ( $this->params ['page'] ) ? $this->params ['page'] : 1;
  544. //
  545. if ($on_page <= 0)
  546. $on_page = 1;
  547. $page_size = 10;
  548. // //检索条件
  549. if($cid==$this->column['TRAINC'])
  550. $n = " and a_type=2 and cid =" . $cid .' and title!=""';
  551. else
  552. $n = " and a_type=1 and cid =" . $cid .' and title!=""';
  553. $condition=$n;
  554. $action = "/news/";
  555. Load::logic ( 'Admin' );
  556. $this->adminlogic = new AdminLogic ();
  557. //获取分页相关数据
  558. $page = $this->adminlogic->get_page ( "sc_article", $condition, $on_page, $page_size, $action );
  559. $limit = " order by update_time desc limit " . $page ['lower'] . " , " . $page_size . " ";
  560. Doo::loadModel('Article');
  561. $article=new Article();
  562. // $k=$article->getOne(array ('where' => 'aid=721' , 'asArray' => TRUE ));
  563. //
  564. // print_r();
  565. //echo $condition;
  566. $page ['article_list'] = $article->getArticleList ( array (), $condition, $limit );
  567. $data['articleInfo']=array();
  568. if(empty($aid)){
  569. if(!empty($page ['article_list']))
  570. $data['articleInfo']=$page ['article_list'][0];
  571. }else{
  572. $a=$article->getArticleById($aid);
  573. $data['articleInfo']=$a[0];
  574. }
  575. foreach ($page ['article_list'] as $key=>$value){
  576. if(empty($value['thum']))
  577. $page ['article_list'][$key]['thum']='/global/img/2.png';
  578. }
  579. $data ['article'] = $page;
  580. $k="";
  581. for ($i=1;$i<=$page['total_page'];$i++){
  582. if($on_page==$i)
  583. $k.="<option value='".$cid.":".$i."' selected>第".$i."页</option>";
  584. else
  585. $k.="<option value='".$cid.":".$i."'>第".$i."页</option>";
  586. }
  587. $data['page']=$page;
  588. $data['comart']=$this->comart;
  589. $data['onpage']=$on_page;
  590. $data['cid']=$cid;
  591. $data['aid']=$aid;
  592. $data['column']=$this->column;
  593. $data['map']='news';
  594. $this->render ( "/news2", $data );
  595. }
  596. function newsPage(){
  597. $aid=isset($this->params ['aid'])&&is_numeric($this->params['aid'])?$this->params['aid']:0;
  598. Doo::loadModel('Article');
  599. $article=new Article();
  600. $a=$article->getArticleById($aid);
  601. $list=$article->find(array ( 'where' => 'aid !=' . $a[0]['aid'].' and cid='.$a[0]['cid'], 'limit'=>'5','desc'=>'aid' ,'asArray' => TRUE ));
  602. $data['list']=$list;
  603. $data['cid']=$a[0]['cid'];
  604. $data['articleInfo']=$a[0];
  605. $data['comart']=$this->comart;
  606. $data['aid']=$aid;
  607. $data['column']=$this->column;
  608. $data['map']='news';
  609. $this->render ( "/newsContent", $data );
  610. }
  611. function video(){
  612. Doo::loadModel('Animation');
  613. $animation=new Animation();
  614. $data['comart']=$this->comart;
  615. $data['map']='video';
  616. if(isset($this->params['aid'])){
  617. $data['nimationInfo']=$animation->getAnimationById($this->params['aid']);
  618. $this->render ( "/videoPage", $data );
  619. }else{
  620. $data['nimation']=$animation->getAnimationList(array(), "", "order by aid asc");
  621. $this->render ( "/video", $data );
  622. }
  623. }
  624. function sdown(){
  625. $url=isset($this->params ['url'])?$this->params['url']:0;
  626. if(!empty($url)){
  627. $url=base64_decode($url);
  628. if(!empty($url))
  629. return $url;
  630. }else{
  631. return "/";
  632. }
  633. }
  634. function getInfo(){
  635. $article=new Article();
  636. $info=$article->getArticleByCid($this->column['COMPANY'],2);
  637. $k=array();
  638. foreach ($info as $key=>$value){
  639. array_push($k, array('aid'=>$value['aid'],'title'=>$value['title']));
  640. }
  641. $pa['company']=$k;
  642. $cid=$this->column['TRAINC'];
  643. $art=$article->getArticleByCid($cid,3);
  644. $k=array();//,'timeStuts'=>getTrainTimeTk($value['enroll_time'])
  645. foreach ($art as $key=>$value){
  646. array_push($k, array('aid'=>$value['aid'],'title'=>$value['enroll_title']));
  647. }
  648. $pa['trainc']=$k;
  649. echo json_encode($pa);
  650. }
  651. function getInfo2(){
  652. $article=new Article();
  653. $info=$article->getArticleByCid($this->column['COMPANY'],6);
  654. $k=array();
  655. foreach ($info as $key=>$value){
  656. array_push($k, array('aid'=>$value['aid'],'title'=>$value['title']));
  657. }
  658. $pa['company']=$k;
  659. $cid=$this->column['TRAINC'];
  660. $art=$article->getArticleByCid($cid,3);
  661. $k=array();//,'timeStuts'=>getTrainTimeTk($value['enroll_time'])
  662. foreach ($art as $key=>$value){
  663. array_push($k, array('aid'=>$value['aid'],'title'=>$value['enroll_title']));
  664. }
  665. $pa['trainc']=$k;
  666. echo json_encode($pa);
  667. }
  668. function newsHttp(){
  669. $updateTime = $this->get_args('updateTime')&&is_numeric($this->get_args('updateTime')) ? $this->get_args('updateTime') : 0;
  670. $page = $this->get_args('page')&&is_numeric($this->get_args('page')) ? $this->get_args('page') : 1;
  671. $size = $this->get_args('size')&&is_numeric($this->get_args('size')) ? $this->get_args('size') : 10;
  672. Doo::loadModel('Article');
  673. $article=new Article();
  674. if ($page!=1)
  675. $page=$page*$size-1;
  676. else
  677. $page--;
  678. $count=$article->count(array('where'=>'title!="" and (update_time>'.$updateTime.')','limit'=>$page.','.$size,'asArray'=>true));
  679. $list=$article->find(array('where'=>'title!="" and (update_time>'.$updateTime.')','limit'=>$page.','.$size,'desc'=>'update_time','asArray'=>true));
  680. echo json_encode(array('status'=>1,'articleList'=>$list,'count'=>$count));
  681. }
  682. function authentication(){
  683. $data=array();
  684. $this->render ( "/productSecurity", $data );
  685. }
  686. function doAuthentication(){
  687. $key = $this->get_args('key')? $this->get_args('key') :"";
  688. $data['comart']=$this->comart;
  689. if (!empty($key)){
  690. require_once (SITE_PATH . '/protected/class/client.php');
  691. $client = new client ( 'http://cld.smartcost.com.cn/' );
  692. $list = $client->zhsso_getSerialNumber ( $key );
  693. $list=json_decode($list,true);
  694. if (empty($list['list'])){
  695. $this->render ( "/productSecurityPiracy", $data );die;
  696. }
  697. $data['list']=$list['list'];
  698. $this->render ( "/productSecurityGenuine", $data );
  699. }else
  700. $this->render ( "/productSecurityPiracy", $data );die;
  701. }
  702. function authenticationHttp(){
  703. $SerialNumber = $this->get_args('SerialNumber')? $this->get_args('SerialNumber') :"";
  704. $data['comart']=$this->comart;
  705. if (!empty($SerialNumber)){
  706. require_once (SITE_PATH . '/protected/class/client.php');
  707. $client = new client ( 'http://cld.smartcost.com.cn/' );
  708. $list = $client->zhsso_getSerialNumber2 ( $SerialNumber );
  709. $list=json_decode($list,true);
  710. if (empty($list['list'])){
  711. $this->render ( "/productSecurityPiracy", $data );die;
  712. }
  713. $data['list']=$list['list'];
  714. $this->render ( "/productSecurityGenuine2", $data );
  715. }else{
  716. $this->render ( "/productSecurityPiracy", $data );die;
  717. }
  718. }
  719. function cut_str($string, $length, $dot = ' ...'){
  720. if(strlen($string) <= $length)
  721. {
  722. return $string;
  723. }
  724. $strcut = '';
  725. $sys_config = 'utf-8';
  726. if($sys_config == 'utf-8'){
  727. $n = $tn = $noc = 0;
  728. while($n < strlen($string))
  729. {
  730. $t = ord($string[$n]);
  731. if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) {
  732. $tn = 1; $n++; $noc++;
  733. } elseif(194 <= $t && $t <= 223) {
  734. $tn = 2; $n += 2; $noc += 2;
  735. } elseif(224 <= $t && $t < 239) {
  736. $tn = 3; $n += 3; $noc += 2;
  737. } elseif(240 <= $t && $t <= 247) {
  738. $tn = 4; $n += 4; $noc += 2;
  739. } elseif(248 <= $t && $t <= 251) {
  740. $tn = 5; $n += 5; $noc += 2;
  741. } elseif($t == 252 || $t == 253) {
  742. $tn = 6; $n += 6; $noc += 2;
  743. } else {
  744. $n++;
  745. }
  746. if($noc >= $length)
  747. {
  748. break;
  749. }
  750. }
  751. if($noc > $length)
  752. {
  753. $n -= $tn;
  754. }
  755. $strcut = mb_substr($string, 0, $n);
  756. }
  757. else
  758. {
  759. for($i = 0; $i < $length; $i++)
  760. {
  761. $strcut .= ord($string[$i]) > 127 ? $string[$i].$string[++$i] : $string[$i];
  762. }
  763. }
  764. return $strcut.$dot;
  765. }
  766. /**
  767. * 获取get或者POST值
  768. * @param string $name 属性名称
  769. * @return fixed 值
  770. */
  771. function get_args($name) {
  772. if (isset ( $_GET [$name] )) {
  773. if (is_array ( $_GET [$name] ))
  774. return $_GET [$name];
  775. else
  776. return addslashes ( $_GET [$name] );
  777. } elseif (isset ( $_POST [$name] )) {
  778. if (is_array ( $_POST [$name] ))
  779. return $_POST [$name];
  780. else
  781. return addslashes ( $_POST [$name] );
  782. } else {
  783. return false;
  784. }
  785. }
  786. }
  787. ?>