ItemController.class.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <?php
  2. namespace Api\Controller;
  3. use Think\Controller;
  4. class ItemController extends BaseController {
  5. //单个项目信息
  6. public function info(){
  7. $this->checkLogin(false);
  8. $item_id = I("item_id/s");
  9. $item_domain = I("item_domain/s");
  10. $current_page_id = I("page_id/d");
  11. if (! is_numeric($item_id)) {
  12. $item_domain = $item_id ;
  13. }
  14. //判断个性域名
  15. if ($item_domain) {
  16. $item = D("Item")->where("item_domain = '%s'",array($item_domain))->find();
  17. if ($item['item_id']) {
  18. $item_id = $item['item_id'] ;
  19. }
  20. }
  21. $login_user = session("login_user");
  22. $uid = $login_user['uid'] ? $login_user['uid'] : 0 ;
  23. if(!$this->checkItemVisit($uid , $item_id)){
  24. $this->sendError(10303);
  25. return ;
  26. }
  27. $item = D("Item")->where("item_id = '%d' ",array($item_id))->find();
  28. if (!$item || $item['is_del'] == 1) {
  29. sleep(1);
  30. $this->sendError(10101,'项目不存在或者已删除');
  31. return false;
  32. }
  33. //从2020.7.5开始,常规项目和单页项目合并在一起返回
  34. $this->_show_regular_item($item);
  35. }
  36. //展示常规项目
  37. private function _show_regular_item($item){
  38. $item_id = $item['item_id'];
  39. $default_page_id = I("default_page_id/d");
  40. $current_page_id = I("page_id/d");
  41. $keyword = I("keyword");
  42. $default_cat_id2 = $default_cat_id3 = 0 ;
  43. $login_user = session("login_user");
  44. $uid = $login_user['uid'] ? $login_user['uid'] : 0 ;
  45. $is_login = $uid > 0 ? true :false;
  46. $menu = array(
  47. "pages" =>array(),
  48. "catalogs" =>array(),
  49. );
  50. //是否有搜索词
  51. if ($keyword) {
  52. $keyword = strtolower ($keyword) ;
  53. $keyword = \SQLite3::escapeString($keyword) ;
  54. $pages = D("Page")->where("item_id = '$item_id' and is_del = 0 and ( lower(page_title) like '%{$keyword}%' or lower(page_content) like '%{$keyword}%' ) ")->order(" s_number asc ")->field("page_id,author_uid,cat_id,page_title,addtime")->select();
  55. $menu['pages'] = $pages ? $pages : array();
  56. }else{
  57. $menu = D("Item")->getMemu($item_id) ;
  58. if($uid > 0 ){
  59. $menu = D("Item")->filteMemberItem($uid , $item_id , $menu);
  60. }
  61. }
  62. $domain = $item['item_domain'] ? $item['item_domain'] : $item['item_id'];
  63. $share_url = get_domain().__APP__.'/'.$domain;
  64. $item_edit = $this->checkItemEdit($uid , $item_id) ;
  65. $item_manage = $this->checkItemManage($uid , $item_id);
  66. //如果带了默认展开的页面id,则获取该页面所在的二级目录/三级目录/四级目录
  67. if ($default_page_id) {
  68. $page = D("Page")->where(" page_id = '$default_page_id' ")->find();
  69. if ($page) {
  70. $default_cat_id4 = $page['cat_id'] ;
  71. $cat1 = D("Catalog")->where(" cat_id = '$default_cat_id4' and parent_cat_id > 0 ")->find();
  72. if ($cat1) {
  73. $default_cat_id3 = $cat1['parent_cat_id'];
  74. }else{
  75. $default_cat_id3 = $default_cat_id4;
  76. $default_cat_id4 = 0 ;
  77. }
  78. $cat2 = D("Catalog")->where(" cat_id = '$default_cat_id3' and parent_cat_id > 0 ")->find();
  79. if ($cat2) {
  80. $default_cat_id2 = $cat2['parent_cat_id'];
  81. }else{
  82. $default_cat_id2 = $default_cat_id3;
  83. $default_cat_id3 = 0 ;
  84. }
  85. }
  86. }
  87. if (LANG_SET == 'en-us') {
  88. $help_url = "https://www.showdoc.cc/help-en";
  89. }
  90. else{
  91. $help_url = "https://www.showdoc.cc/help";
  92. }
  93. //当已经归档了,则去掉编辑权限
  94. if($item['is_archived']){
  95. $item_edit = $item_manage = false;
  96. }
  97. //如果项目类型为runapi,则获取看看有没有全局参数
  98. $global_param = array() ;
  99. if($item['item_type'] == 3){
  100. $global_param = D("Runapi")->getGlobalParam($item_id);
  101. }
  102. $return = array(
  103. "item_id"=>$item_id ,
  104. "item_domain"=>$item['item_domain'] ,
  105. "is_archived"=>$item['is_archived'] ,
  106. "item_name"=>$item['item_name'] ,
  107. "default_page_id"=>(string)$default_page_id ,
  108. "default_cat_id2"=>$default_cat_id2 ,
  109. "default_cat_id3"=>$default_cat_id3 ,
  110. "default_cat_id4"=>$default_cat_id4 ,
  111. "unread_count"=>$unread_count ,
  112. "item_type"=>$item['item_type'] ,
  113. "menu"=>$menu ,
  114. "is_login"=>$is_login,
  115. "item_edit"=>$item_edit ,
  116. "item_manage"=>$item_manage ,
  117. "ItemPermn"=>$item_edit , // ItemPermn 和 ItemCreator这两个字段是为了兼容历史。确保各大客户端(web/手机/runapi)改用字段后可以去掉
  118. "ItemCreator"=>$item_manage ,
  119. "current_page_id"=>$current_page_id ,
  120. "global_param"=>$global_param ,
  121. );
  122. $this->sendResult($return);
  123. }
  124. //我的项目列表
  125. public function myList(){
  126. $login_user = $this->checkLogin();
  127. $original = I("original/d") ? I("original/d") : 0; //1:只返回自己原创的项目;默认是0
  128. $item_group_id = I("item_group_id/d") ? I("item_group_id/d") : 0; //项目分组id。默认是0
  129. $where = "uid = '$login_user[uid]' " ;
  130. $member_item_ids = array(-1) ;
  131. $item_members = D("ItemMember")->where("uid = '$login_user[uid]'")->select();
  132. if ($item_members) {
  133. foreach ($item_members as $key => $value) {
  134. $member_item_ids[] = $value['item_id'] ;
  135. }
  136. }
  137. $team_item_members = D("TeamItemMember")->where("member_uid = '$login_user[uid]'")->select();
  138. if ($team_item_members) {
  139. foreach ($team_item_members as $key => $value) {
  140. $member_item_ids[] = $value['item_id'] ;
  141. }
  142. }
  143. $where .= " or item_id in ( ".implode(",", $member_item_ids)." ) ";
  144. if($item_group_id){
  145. $res = D("ItemGroup")->where(" id = '$item_group_id' ")->find();
  146. if($res){
  147. $where = " ({$where}) and item_id in ({$res['item_ids']}) ";
  148. }
  149. }
  150. $items = D("Item")->field("item_id,uid,item_name,item_domain,item_type,last_update_time,item_description,is_del,password")->where($where)->order("item_id asc")->select();
  151. foreach ($items as $key => $value) {
  152. if ($value['uid'] == $login_user['uid']) {
  153. $items[$key]['creator'] = 1 ;
  154. }else{
  155. $items[$key]['creator'] = 0 ;
  156. unset($items[$key]['password']);
  157. }
  158. //判断是否为私密项目
  159. if ($value['password']) {
  160. $items[$key]['is_private'] = 1 ;
  161. }else{
  162. $items[$key]['is_private'] = 0 ;
  163. }
  164. //如果项目已标识为删除
  165. if ($value['is_del'] == 1) {
  166. unset($items[$key]);
  167. }
  168. //如果有参数指定了只返回原创项目
  169. if($original > 0 && $value['uid'] != $login_user['uid']){
  170. unset($items[$key]);
  171. }
  172. }
  173. $items = array_values($items);
  174. //读取需要置顶的项目
  175. $top_items = D("ItemTop")->where("uid = '$login_user[uid]'")->select();
  176. if ($top_items) {
  177. $top_item_ids = array() ;
  178. foreach ($top_items as $key => $value) {
  179. $top_item_ids[] = $value['item_id'];
  180. }
  181. foreach ($items as $key => $value) {
  182. $items[$key]['top'] = 0 ;
  183. if (in_array($value['item_id'], $top_item_ids) ) {
  184. $items[$key]['top'] = 1 ;
  185. $tmp = $items[$key] ;
  186. unset($items[$key]);
  187. array_unshift($items,$tmp) ;
  188. }
  189. }
  190. }
  191. //读取项目顺序
  192. $item_sort = D("ItemSort")->where("uid = '$login_user[uid]' and item_group_id = '$item_group_id' ")->find();
  193. if ($item_sort) {
  194. $item_sort_data = json_decode(htmlspecialchars_decode($item_sort['item_sort_data']) , true) ;
  195. //var_dump($item_sort_data);
  196. foreach ($items as $key => &$value) {
  197. //如果item_id有设置了序号,则赋值序号。没有则默认填上0
  198. if ($item_sort_data[$value['item_id']]) {
  199. $value['s_number'] = $item_sort_data[$value['item_id']] ;
  200. }else{
  201. $value['s_number'] = 0 ;
  202. }
  203. }
  204. $items = $this->_sort_by_key($items , 's_number' ) ;
  205. }
  206. $items = $items ? array_values($items) : array();
  207. $this->sendResult($items);
  208. // 埋个点,升级数据库
  209. R("Update/checkDb" , array(false));
  210. }
  211. private function _sort_by_key($array , $mykey){
  212. for ($i=0; $i < count($array) ; $i++) {
  213. for ($j = $i + 1 ; $j < count($array) ; $j++) {
  214. if ($array[$i][$mykey] > $array[$j][$mykey] ) {
  215. $tmp = $array[$i] ;
  216. $array[$i] = $array[$j] ;
  217. $array[$j] = $tmp ;
  218. }
  219. }
  220. }
  221. return $array;
  222. }
  223. //项目详情
  224. public function detail(){
  225. $login_user = $this->checkLogin();
  226. $item_id = I("item_id/d");
  227. $uid = $login_user['uid'] ;
  228. if(!$this->checkItemManage($uid , $item_id)){
  229. $this->sendError(10303);
  230. return ;
  231. }
  232. $items = D("Item")->where("item_id = '$item_id' ")->find();
  233. $items = $items ? $items : array();
  234. $this->sendResult($items);
  235. }
  236. //更新项目信息
  237. public function update(){
  238. $login_user = $this->checkLogin();
  239. $item_id = I("item_id/d");
  240. $item_name = I("item_name");
  241. $item_description = I("item_description");
  242. $item_domain = I("item_domain");
  243. $password = I("password");
  244. $uid = $login_user['uid'] ;
  245. if(!$this->checkItemManage($uid , $item_id)){
  246. $this->sendError(10303);
  247. return ;
  248. }
  249. if ($item_domain) {
  250. if(!ctype_alnum($item_domain) || is_numeric($item_domain) ){
  251. //echo '个性域名只能是字母或数字的组合';exit;
  252. $this->sendError(10305);
  253. return false;
  254. }
  255. $item = D("Item")->where("item_domain = '%s' and item_id !='%s' ",array($item_domain,$item_id))->find();
  256. if ($item) {
  257. //个性域名已经存在
  258. $this->sendError(10304);
  259. return false;
  260. }
  261. }
  262. $save_data = array(
  263. "item_name" => $item_name ,
  264. "item_description" => $item_description ,
  265. "item_domain" => $item_domain ,
  266. "password" => $password ,
  267. );
  268. $items = D("Item")->where("item_id = '$item_id' ")->save($save_data);
  269. $items = $items ? $items : array();
  270. $this->sendResult($items);
  271. }
  272. //转让项目
  273. public function attorn(){
  274. $login_user = $this->checkLogin();
  275. $username = I("username");
  276. $item_id = I("item_id/d");
  277. $password = I("password");
  278. $item = D("Item")->where("item_id = '$item_id' ")->find();
  279. if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
  280. $this->sendError(10303);
  281. return ;
  282. }
  283. if(! D("User")-> checkLogin($item['username'],$password)){
  284. $this->sendError(10208);
  285. return ;
  286. }
  287. $member = D("User")->where(" username = '%s' ",array($username))->find();
  288. if (!$member) {
  289. $this->sendError(10209);
  290. return ;
  291. }
  292. $data['username'] = $member['username'] ;
  293. $data['uid'] = $member['uid'] ;
  294. $id = D("Item")->where(" item_id = '$item_id' ")->save($data);
  295. $return = D("Item")->where("item_id = '$item_id' ")->find();
  296. if (!$return) {
  297. $this->sendError(10101);
  298. }
  299. $this->sendResult($return);
  300. }
  301. //删除项目
  302. public function delete(){
  303. $login_user = $this->checkLogin();
  304. $item_id = I("item_id/d");
  305. $password = I("password");
  306. $item = D("Item")->where("item_id = '$item_id' ")->find();
  307. if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
  308. $this->sendError(10303);
  309. return ;
  310. }
  311. if(! D("User")-> checkLogin($item['username'],$password)){
  312. $this->sendError(10208);
  313. return ;
  314. }
  315. $return = D("Item")->soft_delete_item($item_id);
  316. if (!$return) {
  317. $this->sendError(10101);
  318. }else{
  319. }
  320. $this->sendResult($return);
  321. }
  322. //归档项目
  323. public function archive(){
  324. $login_user = $this->checkLogin();
  325. $item_id = I("item_id/d");
  326. $password = I("password");
  327. $item = D("Item")->where("item_id = '$item_id' ")->find();
  328. if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
  329. $this->sendError(10303);
  330. return ;
  331. }
  332. if(! D("User")-> checkLogin($item['username'],$password)){
  333. $this->sendError(10208);
  334. return ;
  335. }
  336. $return = D("Item")->where("item_id = '$item_id' ")->save(array("is_archived"=>1));
  337. if (!$return) {
  338. $this->sendError(10101);
  339. }else{
  340. $this->sendResult($return);
  341. }
  342. }
  343. public function getKey(){
  344. $login_user = $this->checkLogin();
  345. $item_id = I("item_id/d");
  346. $item = D("Item")->where("item_id = '$item_id' ")->find();
  347. if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
  348. $this->sendError(10303);
  349. return ;
  350. }
  351. $item_token = D("ItemToken")->getTokenByItemId($item_id);
  352. if (!$item_token) {
  353. $this->sendError(10101);
  354. }
  355. $this->sendResult($item_token);
  356. }
  357. public function resetKey(){
  358. $login_user = $this->checkLogin();
  359. $item_id = I("item_id/d");
  360. $item = D("Item")->where("item_id = '$item_id' ")->find();
  361. if(!$this->checkItemManage($login_user['uid'] , $item['item_id'])){
  362. $this->sendError(10303);
  363. return ;
  364. }
  365. $ret = D("ItemToken")->where("item_id = '$item_id' ")->delete();
  366. if ($ret) {
  367. $this->getKey();
  368. }else{
  369. $this->sendError(10101);
  370. }
  371. }
  372. public function updateByApi(){
  373. //转到Open控制器的updateItem方法
  374. R('Open/updateItem');
  375. }
  376. //置顶项目
  377. public function top(){
  378. $login_user = $this->checkLogin();
  379. $item_id = I("item_id/d");
  380. $action = I("action");
  381. if ($action == 'top') {
  382. $ret = D("ItemTop")->add(array("item_id"=>$item_id,"uid"=>$login_user['uid'],"addtime"=>time()));
  383. }
  384. elseif ($action == 'cancel') {
  385. $ret = D("ItemTop")->where(" uid = '$login_user[uid]' and item_id = '$item_id' ")->delete();
  386. }
  387. if ($ret) {
  388. $this->sendResult(array());
  389. }else{
  390. $this->sendError(10101);
  391. }
  392. }
  393. //验证访问密码
  394. public function pwd(){
  395. $item_id = I("item_id/d");
  396. $password = I("password");
  397. $v_code = I("v_code");
  398. $refer_url = I('refer_url');
  399. //检查用户输错密码的次数。如果超过一定次数,则需要验证 验证码
  400. $key= 'item_pwd_fail_times_'.$item_id;
  401. if(!D("VerifyCode")->_check_times($key,10)){
  402. if (!$v_code || $v_code != session('v_code')) {
  403. $this->sendError(10206,L('verification_code_are_incorrect'));
  404. return;
  405. }
  406. }
  407. session('v_code',null) ;
  408. $item = D("Item")->where("item_id = '$item_id' ")->find();
  409. if ($item['password'] == $password) {
  410. session("visit_item_".$item_id , 1 );
  411. $this->sendResult(array("refer_url"=>base64_decode($refer_url)));
  412. }else{
  413. D("VerifyCode")->_ins_times($key);//输错密码则设置输错次数
  414. if(D("VerifyCode")->_check_times($key,10)){
  415. $error_code = 10307 ;
  416. }else{
  417. $error_code = 10308 ;
  418. }
  419. $this->sendError($error_code,L('access_password_are_incorrect'));
  420. }
  421. }
  422. public function itemList(){
  423. $login_user = $this->checkLogin();
  424. $items = D("Item")->where("uid = '$login_user[uid]' ")->select();
  425. $items = $items ? $items : array();
  426. $this->sendResult($items);
  427. }
  428. //新建项目
  429. public function add(){
  430. $login_user = $this->checkLogin();
  431. $item_name = I("item_name");
  432. $item_domain = I("item_domain") ? I("item_domain") : '';
  433. $copy_item_id = I("copy_item_id");
  434. $password = I("password");
  435. $item_description = I("item_description");
  436. $item_type = I("item_type") ? I("item_type") : 1 ;
  437. if ($item_domain) {
  438. if(!ctype_alnum($item_domain) || is_numeric($item_domain) ){
  439. //echo '个性域名只能是字母或数字的组合';exit;
  440. $this->sendError(10305);
  441. return false;
  442. }
  443. $item = D("Item")->where("item_domain = '%s' ",array($item_domain))->find();
  444. if ($item) {
  445. //个性域名已经存在
  446. $this->sendError(10304);
  447. return false;
  448. }
  449. }
  450. //如果是复制项目
  451. if ($copy_item_id > 0) {
  452. if (!$this->checkItemEdit($login_user['uid'] , $copy_item_id)) {
  453. $this->sendError(10103);
  454. return;
  455. }
  456. $item_id = D("Item")->copy($copy_item_id,$login_user['uid'],$item_name,$item_description,$password,$item_domain);
  457. if ($item_id) {
  458. $this->sendResult(array("item_id"=>$item_id));
  459. }else{
  460. $this->sendError(10101);
  461. }
  462. return ;
  463. }
  464. $insert = array(
  465. "uid" => $login_user['uid'] ,
  466. "username" => $login_user['username'] ,
  467. "item_name" => $item_name ,
  468. "password" => $password ,
  469. "item_description" => $item_description ,
  470. "item_domain" => $item_domain ,
  471. "item_type" => $item_type ,
  472. "addtime" =>time()
  473. );
  474. $item_id = D("Item")->add($insert);
  475. if ($item_id) {
  476. //如果是单页应用,则新建一个默认页
  477. if ($item_type == 2 ) {
  478. $insert = array(
  479. 'author_uid' => $login_user['uid'] ,
  480. 'author_username' => $login_user['username'],
  481. "page_title" => $item_name ,
  482. "item_id" => $item_id ,
  483. "cat_id" => 0 ,
  484. "page_content" => '欢迎使用showdoc。点击右上方的编辑按钮进行编辑吧!' ,
  485. "addtime" =>time()
  486. );
  487. $page_id = D("Page")->add($insert);
  488. }
  489. //如果是表格应用,则新建一个默认页
  490. if ($item_type == 4 ) {
  491. $insert = array(
  492. 'author_uid' => $login_user['uid'] ,
  493. 'author_username' => $login_user['username'],
  494. "page_title" => $item_name ,
  495. "item_id" => $item_id ,
  496. "cat_id" => 0 ,
  497. "page_content" => '' ,
  498. "addtime" =>time()
  499. );
  500. $page_id = D("Page")->add($insert);
  501. }
  502. $this->sendResult(array("item_id"=>$item_id));
  503. }else{
  504. $this->sendError(10101);
  505. }
  506. }
  507. //保存项目排序
  508. public function sort(){
  509. $login_user = $this->checkLogin();
  510. $data = I("data");
  511. $item_group_id = I("item_group_id/d");
  512. $res = D("ItemSort")->where(" uid ='$login_user[uid]' and item_group_id = $item_group_id ")->find() ;
  513. if($res){
  514. $ret = D("ItemSort")->where(" uid ='$login_user[uid]' and item_group_id = $item_group_id ")->save(array("item_sort_data"=>$data,"addtime"=>time()));
  515. }else{
  516. $ret = D("ItemSort")->add(array("item_sort_data"=>$data,"item_group_id"=>$item_group_id,"uid"=>$login_user['uid'],"addtime"=>time()));
  517. }
  518. if ($ret) {
  519. $this->sendResult(array());
  520. }else{
  521. $this->sendError(10101);
  522. }
  523. }
  524. public function exitItem(){
  525. $login_user = $this->checkLogin();
  526. $item_id = I("item_id/d");
  527. $ret = D("ItemMember")->where("item_id = '$item_id' and uid ='$login_user[uid]' ")->delete();
  528. $row = D("TeamItemMember")->join(" left join team on team.id = team_item_member.team_id ")->where("item_id = '$item_id' and member_uid ='$login_user[uid]' ")->find();
  529. if ($row) {
  530. $ret = D("TeamItemMember")->where(" member_uid = '$login_user[uid]' and team_id = '$row[team_id]' ")->delete();
  531. $ret = D("TeamMember")->where(" member_uid = '$login_user[uid]' and team_id = '$row[team_id]' ")->delete();
  532. }
  533. if ($ret) {
  534. $this->sendResult(array());
  535. }else{
  536. $this->sendError(10101);
  537. }
  538. }
  539. // 在某个项目中根据内容搜索
  540. public function search(){
  541. $keyword = I("keyword");
  542. $item_id = I("item_id/d");
  543. $login_user = $this->checkLogin();
  544. $uid = $login_user['uid'] ;
  545. if(!$this->checkItemVisit($uid , $item_id)){
  546. $this->sendError(10303,"没有权限");
  547. return ;
  548. }
  549. $item = D("Item")->where("item_id = '%d' and is_del = 0 ",array($item_id))->find();
  550. $keyword = \SQLite3::escapeString($keyword) ;
  551. $pages = D("Page")->search($item_id,$keyword) ;
  552. if($pages){
  553. foreach ($pages as $key => $value) {
  554. $page_content = htmlspecialchars_decode($value['page_content']) ;
  555. $pos = mb_strpos($page_content,$keyword) ;
  556. $len = mb_strlen($keyword) ;
  557. $start = ( $pos - 100 ) > 0 ? ( $pos - 100 ) : 0 ;
  558. $pages[$key]['search_content'] = '...'.mb_substr($page_content,$start , ($len + 200 ) ).'...' ;
  559. unset($pages[$key]['page_content']) ;
  560. $pages[$key]['item_id'] = $item['item_id'] ;
  561. $pages[$key]['item_name'] = $item['item_name'] ;
  562. }
  563. }
  564. $return = array(
  565. "item_id"=> $item_id ,
  566. "item_name"=> $item['item_name'] ,
  567. "pages"=>$pages
  568. );
  569. $this->sendResult($return);
  570. }
  571. }