70c139fed11cd09060fbfbc1d5287117.resolve.paths.resolver 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Gallery
  4. *
  5. * Copyright 2010-2012 by Shaun McCormick <shaun@modx.com>
  6. *
  7. * Gallery 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. * Gallery 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. * Gallery; if not, write to the Free Software Foundation, Inc., 59 Temple
  18. * Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * @package gallery
  21. */
  22. /**
  23. * Resolve paths
  24. *
  25. * @var modX $modx
  26. * @var string $key
  27. * @var string $value
  28. * @var xPDOObject $object
  29. * @var array $options
  30. *
  31. * @package gallery
  32. * @subpackage build
  33. */
  34. function createSetting(&$modx,$key,$value) {
  35. $ct = $modx->getCount('modSystemSetting',array(
  36. 'key' => 'gallery.'.$key,
  37. ));
  38. if (empty($ct)) {
  39. /** @var modSystemSetting $setting */
  40. $setting = $modx->newObject('modSystemSetting');
  41. $setting->set('key','gallery.'.$key);
  42. $setting->set('value',$value);
  43. $setting->set('namespace','gallery');
  44. $setting->set('area','Paths');
  45. $setting->save();
  46. }
  47. }
  48. if ($object->xpdo) {
  49. switch ($options[xPDOTransport::PACKAGE_ACTION]) {
  50. case xPDOTransport::ACTION_INSTALL:
  51. $modx =& $object->xpdo;
  52. /* setup paths */
  53. createSetting($modx,'files_path','[[++assets_path]]gallery/');
  54. @mkdir($modx->getOption('assets_path').'gallery/',0775);
  55. /* setup urls */
  56. createSetting($modx,'files_url','[[++assets_url]]gallery/');
  57. break;
  58. case xPDOTransport::ACTION_UPGRADE:
  59. break;
  60. }
  61. }
  62. return true;