modsystemsetting.class.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. require_once (dirname(__DIR__) . '/modsystemsetting.class.php');
  11. /**
  12. * @package modx
  13. * @subpackage sqlsrv
  14. */
  15. class modSystemSetting_sqlsrv extends modSystemSetting {
  16. public static function listSettings(xPDO &$xpdo, array $criteria = array(), array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0) {
  17. /* build query */
  18. $c = $xpdo->newQuery('modSystemSetting');
  19. $c->select(array(
  20. $xpdo->getSelectColumns('modSystemSetting','modSystemSetting'),
  21. ));
  22. $c->select(array(
  23. 'Entry.value AS name_trans',
  24. 'Description.value AS description_trans',
  25. ));
  26. $c->leftJoin('modLexiconEntry','Entry',"'setting_' + modSystemSetting.{$xpdo->escape('key')} = Entry.name");
  27. $c->leftJoin('modLexiconEntry','Description',"'setting_' + modSystemSetting.{$xpdo->escape('key')} + '_desc' = Description.name");
  28. $c->where($criteria);
  29. $count = $xpdo->getCount('modSystemSetting',$c);
  30. $c->sortby($xpdo->getSelectColumns('modSystemSetting','modSystemSetting','',array('area')),'ASC');
  31. foreach($sort as $field=> $dir) {
  32. $c->sortby($xpdo->getSelectColumns('modSystemSetting','modSystemSetting','',array($field)),$dir);
  33. }
  34. if ((int) $limit > 0) {
  35. $c->limit((int) $limit, (int) $offset);
  36. }
  37. return array(
  38. 'count'=> $count,
  39. 'collection'=> $xpdo->getCollection('modSystemSetting',$c)
  40. );
  41. }
  42. }
  43. ?>