UrlConfigController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * 系统URL配置
  4. * @author 2015-10-15
  5. */
  6. class UrlConfigController extends AdminController {
  7. public function actionIndex () {
  8. $this->render('index');
  9. }
  10. public function actionList () {
  11. $criteria = new EMongoCriteria();
  12. $criteria->_id = new MongoRegex('/^pu/');
  13. $cursor = Variable::model()->findAll($criteria);
  14. $rows = CommonFn::getRowsFromCursor($cursor);
  15. $parsedRows = Variable::model()->parse($rows);
  16. $parsedRows = array_values($parsedRows);
  17. echo CommonFn::composeDatagridData($parsedRows, count($parsedRows));
  18. }
  19. public function actionEdit () {
  20. $key = Yii::app()->request->getParam('key');
  21. $value = Yii::app()->request->getParam('value');
  22. if (!$key || !$value) {
  23. CommonFn::requestAjax(false, '缺少必须参数');
  24. }
  25. $regex = '/^pu/';
  26. if (empty(preg_grep($regex, array($key)))) {
  27. CommonFn::requestAjax(false, '配置名不符合规范');
  28. }
  29. $success = Service::factory('VariableService')->setVariable($key, $value);
  30. CommonFn::requestAjax($success, '', array());
  31. }
  32. }
  33. ?>