16.include.cache.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * ClientConfig
  4. *
  5. * Copyright 2011-2014 by Mark Hamstra <hello@markhamstra.com>
  6. *
  7. * ClientConfig is free software; you can redistribute it and/or modify it under the
  8. * terms of the GNU General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option) any later
  10. * version.
  11. *
  12. * ClientConfig is distributed in the hope that it will be useful, but WITHOUT ANY
  13. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  14. * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * ClientConfig; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. * Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * @package clientconfig
  21. *
  22. * @var modX $modx
  23. * @var int $id
  24. * @var string $mode
  25. * @var modResource $resource
  26. * @var modTemplate $template
  27. * @var modTemplateVar $tv
  28. * @var modChunk $chunk
  29. * @var modSnippet $snippet
  30. * @var modPlugin $plugin
  31. */
  32. $eventName = $modx->event->name;
  33. switch($eventName) {
  34. case 'OnMODXInit':
  35. case 'OnHandleRequest':
  36. /* Grab the class */
  37. $path = $modx->getOption('clientconfig.core_path', null, $modx->getOption('core_path') . 'components/clientconfig/');
  38. $path .= 'model/clientconfig/';
  39. $clientConfig = $modx->getService('clientconfig','ClientConfig', $path);
  40. /* If we got the class (gotta be careful of failed migrations), grab settings and go! */
  41. if ($clientConfig instanceof ClientConfig) {
  42. $contextKey = $modx->context instanceof modContext ? $modx->context->get('key') : 'web';
  43. $settings = $clientConfig->getSettings($contextKey);
  44. /* Make settings available as [[++tags]] */
  45. $modx->setPlaceholders($settings, '+');
  46. /* Make settings available for $modx->getOption() */
  47. foreach ($settings as $key => $value) {
  48. $modx->setOption($key, $value);
  49. }
  50. }
  51. break;
  52. }
  53. return;
  54. return;