PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/testSource/phpcms/content/application/controllers/test.php

https://gitlab.com/loda.sun.suryani/qijiatuku
PHP | 198 lines | 158 code | 19 blank | 21 comment | 11 complexity | a60095f2f8fd3619343d44ff4f4be042 MD5 | raw file
  1. <?php
  2. /**
  3. * Class untuk test library datagrid
  4. *
  5. * @author Permana
  6. *
  7. * @property Datagrid $datagrid
  8. */
  9. class Test extends CI_Controller
  10. {
  11. function __construct()
  12. {
  13. parent::__construct();
  14. $this->load->helper('html');
  15. $this->load->library('datagrid');
  16. }
  17. function index()
  18. {
  19. $this->load->library('phpconsole');
  20. $this->phpconsole->log(__LINE__, __FILE__);
  21. $this->phpconsole->log(__LINE__, date('Y-m-d H:i:s', time()));
  22. $this->phpconsole->flush();
  23. $this->phpconsole->log(__LINE__, __FILE__);
  24. $this->phpconsole->log(__LINE__, date('Y-m-d H:i:s', time()));
  25. $this->phpconsole->log(__LINE__, "test(测试)...");
  26. exit(__FILE__ . ":" . __LINE__);
  27. }
  28. function batch_publish()
  29. {
  30. return;
  31. /*
  32. * 批量发布.
  33. * 这不是真的发布,只是在文件同步表中插入记录,省去手动点击.
  34. * 仅适用于紧急情况下的修复
  35. */
  36. $this->db_online = $this->load->database('online', true);
  37. $rows = $this->db_online->get_rows_by_sql(
  38. "SELECT page_id,page_title,page_site,page_url FROM (`cms_page`) WHERE page_site='mall.jia.com' AND is_static=1 ");
  39. $this->datagrid->reset();
  40. echo $this->datagrid->build('datagrid', $rows, TRUE);
  41. $this->db_online->query("SET AUTOCOMMIT=0");
  42. $this->db_online->query("BEGIN");
  43. foreach ($rows as $row) {
  44. $this->db_online->where('page_id', $row ['page_id']);
  45. $this->db_online->delete('cms_sync_log');
  46. $this->db_online->insert('cms_sync_log',
  47. array('page_id' => $row ['page_id'], 'client_ip' => '10.10.20.131'));
  48. }
  49. $this->db_online->query("COMMIT");
  50. }
  51. function form()
  52. {
  53. $data = array();
  54. $id = $this->input->get('id');
  55. $sql = "SELECT page_tpl_name FROM cms_page_tpl WHERE page_tpl_id ='$id'";
  56. $result = $this->db->get_record_by_sql($sql);
  57. //my_debug($result);
  58. $data ['page_tpl_name'] = $result['page_tpl_name'];
  59. $this->load->view('jqgrid/from_views', $data);
  60. }
  61. public function grid_index()
  62. {
  63. $success = '';
  64. error_reporting(E_ALL);
  65. $data = array();
  66. //=============加载编辑器{{=============================================
  67. $this->load->library('editors');
  68. $eddt = array('id' => 'notice_content', 'value' => '', 'width' => '600px', 'height' => '200px');
  69. $data ['notice_content'] = $this->editors->getedit($eddt);
  70. $cloumn = "page_tpl_id,page_tpl_name,layout_pic_id,create_time,user_id";
  71. $data ['cloumn'] = $cloumn;
  72. $this->load->view('jqgrid/jqgrid_index_views', $data);
  73. }
  74. public function show()
  75. {
  76. $sql = "";
  77. if ($_GET ['_search'] == 'true') {
  78. $searchString = $this->input->get("searchString"); //字段的数值
  79. $searchOper = $this->input->get("searchOper"); //判断符号
  80. $searchField = $this->input->get("searchField"); //字段
  81. if ($searchOper == "eq") {
  82. $sql = " WHERE $searchField ='$searchString'";
  83. }
  84. }
  85. $page = $_GET ['page']; // get the requested page
  86. $limit = $_GET ['rows']; // get how many rows we want to have into the grid
  87. $sidx = $_GET ['sidx']; // get index row - i.e. user click to sort
  88. $sord = $_GET ['sord']; // get the direction
  89. if (!$sidx)
  90. $sidx = 1;
  91. $sql_count = "SELECT count(*) as count FROM cms_page_tpl $sql"; //取总数,用于分页
  92. $row = $this->db->get_record_by_sql($sql_count);
  93. $count = $row ['count']; //取得总数
  94. if ($count > 0) {
  95. $total_pages = ceil($count / $limit);
  96. } else {
  97. $total_pages = 0;
  98. }
  99. if ($page > $total_pages)
  100. $page = $total_pages;
  101. $start = $limit * $page - $limit; // do not put $limit*($page - 1)
  102. if ($start < 0) {
  103. $start = 0;
  104. }
  105. $clumn = "page_tpl_id,page_tpl_name,layout_pic_id,create_time,user_id";
  106. $sql = "SELECT $clumn FROM cms_page_tpl $sql ORDER BY page_tpl_id $sord LIMIT $start , $limit";
  107. $result = $this->db->get_rows_by_sql($sql);
  108. $responce = "";
  109. $responce->page = $page;
  110. $responce->total = $total_pages;
  111. $responce->records = $count;
  112. $i = 0;
  113. if (count($result)) {
  114. foreach ($result as $k => $row) {
  115. $user_id = $row ['user_id'];
  116. $sql_u = "SELECT user_name FROM cms_user WHERE user_id='$user_id' ";
  117. $row_u = $this->db->get_record_by_sql($sql_u);
  118. $responce->rows [$i] ['id'] = $row ['page_tpl_id']; //行ID,是grid规定不可重复的ID标示
  119. $responce->rows [$i] ['cell'] = array(
  120. $row ['page_tpl_id'],
  121. $row ["page_tpl_name"],
  122. $row ["layout_pic_id"],
  123. date("Y-m-d", $row ["create_time"]),
  124. $row_u ['user_name'],
  125. "");
  126. $i++;
  127. }
  128. } else { //当积累为空的时候 ,防止js报错,赋值为空即可
  129. $responce->rows [$i] ['id'] = ''; //行ID,是grid规定不可重复的ID标示
  130. $responce->rows [$i] ['cell'] = array('', '', '', '', '', '');
  131. }
  132. echo json_encode($responce);
  133. }
  134. public function add()
  135. {
  136. //print_r ( $_REQUEST );
  137. $arr = $_REQUEST;
  138. $success = 1;
  139. echo $success;
  140. }
  141. public function edit()
  142. {
  143. //print_r ( $_REQUEST );
  144. //
  145. $arr = $_REQUEST;
  146. $insert = array('page_tpl_name' => $arr ['page_tpl_name']);
  147. $this->db->where("page_tpl_id", $arr ['id']);
  148. $success = $this->db->update("cms_page_tpl", $insert);
  149. echo $success;
  150. echo "<script>if(parent.window.close_dialog){parent.window.close_dialog();}</script>";
  151. }
  152. public function del()
  153. {
  154. $id = $this->input->post("id");
  155. $this->db->where_in("page_tpl_id", $id);
  156. //$success = $this->db->delete ( "cms_page_tpl" );
  157. echo $id;
  158. }
  159. public function convert_csv()
  160. {
  161. $fn = FCPATH . "llg.csv";
  162. //var_dump($fn);
  163. $rows = file($fn);
  164. $todo = array("symbol" => "XAUUSD", "zoom" => "d1");
  165. foreach ($rows as $row) {
  166. $fields = explode(",", $row);
  167. //var_dump($fields);
  168. $todo["datetime"] = trim(str_replace(".", "", $fields[0]));
  169. $todo["open"] = trim($fields[2]);
  170. $todo["high"] = trim($fields[3]);
  171. $todo["low"] = trim($fields[4]);
  172. $todo["close"] = trim($fields[5]);
  173. $todo["volumn"] = trim($fields[6]);
  174. $this->db->insert("chart_data", $todo);
  175. echo ".";
  176. }
  177. }
  178. }
  179. //end.