StaticSourceController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * 系统静态资源配置
  4. */
  5. class StaticSourceController extends AdminController {
  6. public function actionIndex() {
  7. $this->render('index');
  8. }
  9. public function actionList() {
  10. $cursor = StaticSource::model()->findAll();
  11. $count = $cursor->count();
  12. $rows = CommonFn::getRowsFromCursor($cursor);
  13. $parsedRows = StaticSource::model()->parse($rows);
  14. echo CommonFn::composeDatagridData($parsedRows, $count);
  15. }
  16. public function actionEdit() {
  17. $id = Yii::app()->request->getParam('id', '');
  18. $key = Yii::app()->request->getParam('key', '');
  19. $title = Yii::app()->request->getParam('title', '');
  20. $content = Yii::app()->request->getParam('editorValue', '');
  21. $remark = Yii::app()->request->getParam('remark', '');
  22. if (!$key) {
  23. CommonFn::requestAjax(true, '请检查Key');
  24. }
  25. $temp = StaticSource::getByKey($key);
  26. if (!$id) {
  27. $static = new StaticSource();
  28. if ($temp) {
  29. CommonFn::requestAjax(false, '键值已存在');
  30. }
  31. } else {
  32. $static = StaticSource::get(new MongoId($id));
  33. if ($temp && $temp->_id != $static->_id) {
  34. CommonFn::requestAjax(false, '键值已存在');
  35. }
  36. }
  37. $static->key = $key;
  38. $static->title = $title;
  39. $static->content = $content;
  40. $static->remark = $remark;
  41. $static->save();
  42. CommonFn::requestAjax(true, '', []);
  43. }
  44. }