gallerycustomtv.plugin.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * Handles plugin events for Gallery's Custom TV
  4. *
  5. * @package gallery
  6. */
  7. $corePath = $modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/');
  8. switch ($modx->event->name) {
  9. case 'OnTVInputRenderList':
  10. $modx->event->output($corePath.'elements/tv/input/');
  11. break;
  12. case 'OnTVOutputRenderList':
  13. $modx->event->output($corePath.'elements/tv/output/');
  14. break;
  15. case 'OnTVInputPropertiesList':
  16. $modx->event->output($corePath.'elements/tv/inputoptions/');
  17. break;
  18. case 'OnTVOutputRenderPropertiesList':
  19. $modx->event->output($corePath.'elements/tv/properties/');
  20. break;
  21. case 'OnManagerPageBeforeRender':
  22. $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
  23. if (!($gallery instanceof Gallery)) return '';
  24. $snippetIds = '';
  25. $gallerySnippet = $modx->getObject('modSnippet',array('name' => 'Gallery'));
  26. if ($gallerySnippet) {
  27. $snippetIds .= 'GAL.snippetGallery = "'.$gallerySnippet->get('id').'";'."\n";
  28. }
  29. $galleryItemSnippet = $modx->getObject('modSnippet',array('name' => 'GalleryItem'));
  30. if ($galleryItemSnippet) {
  31. $snippetIds .= 'GAL.snippetGalleryItem = "'.$galleryItemSnippet->get('id').'";'."\n";
  32. }
  33. $jsDir = $modx->getOption('gallery.assets_url',null,$modx->getOption('assets_url').'components/gallery/').'js/mgr/';
  34. $modx->controller->addLexiconTopic('gallery:default');
  35. $modx->controller->addJavascript($jsDir.'gallery.js');
  36. $modx->controller->addJavascript($jsDir.'tree.js');
  37. $modx->controller->addHtml('<script type="text/javascript">
  38. Ext.onReady(function() {
  39. GAL.config.connector_url = "'.$gallery->config['connectorUrl'].'";
  40. '.$snippetIds.'
  41. });
  42. </script>');
  43. break;
  44. case 'OnDocFormPrerender':
  45. $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties);
  46. if (!($gallery instanceof Gallery)) return '';
  47. /* assign gallery lang to JS */
  48. $modx->controller->addLexiconTopic('gallery:tv');
  49. /* @var modAction $action */
  50. $action = $modx->getObject('modAction',array(
  51. 'namespace' => 'gallery',
  52. 'controller' => 'index',
  53. ));
  54. $modx->controller->addHtml('<script type="text/javascript">
  55. Ext.onReady(function() {
  56. GAL.config = {};
  57. GAL.config.connector_url = "'.$gallery->config['connectorUrl'].'";
  58. GAL.action = "'.($action ? $action->get('id') : 0).'";
  59. });
  60. </script>');
  61. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/tv/Spotlight.js');
  62. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/gallery.js');
  63. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/widgets/album/album.items.view.js');
  64. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/widgets/album/album.tree.js');
  65. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/tv/gal.browser.js');
  66. $modx->controller->addJavascript($gallery->config['assetsUrl'].'js/mgr/tv/galtv.js');
  67. $modx->controller->addCss($gallery->config['cssUrl'].'mgr.css');
  68. break;
  69. }
  70. return;