update.class.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. * Loads the album editing page.
  24. *
  25. * @package gallery
  26. * @subpackage controllers
  27. * @var modX $this->modx
  28. * @var Gallery $gallery
  29. */
  30. class GalleryAlbumUpdateManagerController extends GalleryManagerController {
  31. public function getPageTitle() { return $this->modx->lexicon('gallery.album_update'); }
  32. public function loadCustomCssJs() {
  33. $this->addJavascript($this->modx->getOption('manager_url').'assets/modext/core/modx.view.js');
  34. $this->addJavascript($this->gallery->config['jsUrl'].'mgr/utils/ddview.js');
  35. $this->addJavascript($this->gallery->config['jsUrl'].'mgr/utils/fileuploader.js');
  36. $this->addJavascript($this->gallery->config['jsUrl'].'mgr/widgets/album/album.items.view.js');
  37. $this->addJavascript($this->gallery->config['jsUrl'].'mgr/widgets/album/album.panel.js');
  38. $this->addLastJavascript($this->gallery->config['jsUrl'].'mgr/sections/album/update.js');
  39. $this->addCss($this->gallery->config['cssUrl'].'fileuploader.css');
  40. $this->addHtml("<script>Ext.onReady(function() { MODx.load({xtype: 'gal-page-album-update'}) })</script>");
  41. $this->checkForTinyMCE();
  42. }
  43. public function getTemplateFile() { return $this->gallery->config['templatesPath'].'album/update.tpl'; }
  44. public function checkForTinyMCE() {
  45. /* If we want to use Tiny, we'll need some extra files. */
  46. $useTiny = $this->modx->getOption('gallery.use_richtext',$this->gallery->config,false);
  47. if ($useTiny) {
  48. $tinyCorePath = $this->modx->getOption('tiny.core_path',null,$this->modx->getOption('core_path').'components/tinymce/');
  49. if (file_exists($tinyCorePath.'tinymce.class.php')) {
  50. /* First fetch the gallery+tiny specific settings */
  51. $cb1 = $this->modx->getOption('gallery.tiny.buttons1',null,'undo,redo,selectall,pastetext,pasteword,charmap,separator,image,modxlink,unlink,media,separator,code,help');
  52. $cb2 = $this->modx->getOption('gallery.tiny.buttons2',null,'bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull');
  53. $cb3 = $this->modx->getOption('gallery.tiny.buttons3',null,'styleselect,formatselect,separator,styleprops');
  54. $cb4 = $this->modx->getOption('gallery.tiny.buttons4',null,'');
  55. $cb5 = $this->modx->getOption('gallery.tiny.buttons5',null,'');
  56. $plugins = $this->modx->getOption('gallery.tiny.custom_plugins',null,'');
  57. $theme = $this->modx->getOption('gallery.tiny.theme',null,'');
  58. $bfs = $this->modx->getOption('gallery.tiny.theme_advanced_blockformats',null,'');
  59. $css = $this->modx->getOption('gallery.tiny.theme_advanced_css_selectors',null,'');
  60. /** @var modAction $browserAction */
  61. $browserAction = $this->modx->getObject('modAction',array('controller' => 'browser'));
  62. /* If the settings are empty, override them with the generic tinymce settings. */
  63. $tinyProperties = array(
  64. 'accessibility_warnings' => false,
  65. 'browserUrl' => $browserAction ? $this->modx->getOption('manager_url',null,MODX_MANAGER_URL).'index.php?a='.$browserAction->get('id').'&source=1' : null,
  66. 'cleanup' => true,
  67. 'cleanup_on_startup' => false,
  68. 'compressor' => '',
  69. 'execcommand_callback' => 'Tiny.onExecCommand',
  70. 'file_browser_callback' => 'Tiny.loadBrowser',
  71. 'force_p_newlines' => true,
  72. 'force_br_newlines' => false,
  73. 'formats' => array(
  74. 'alignleft' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyleft'),
  75. 'alignright' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyright'),
  76. 'alignfull' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyfull'),
  77. ),
  78. 'frontend' => false,
  79. 'plugin_insertdate_dateFormat' => '%Y-%m-%d',
  80. 'plugin_insertdate_timeFormat' => '%H:%M:%S',
  81. 'preformatted' => false,
  82. 'resizable' => true,
  83. 'relative_urls' => true,
  84. 'remove_script_host' => true,
  85. 'theme_advanced_disable' => '',
  86. 'theme_advanced_resizing' => true,
  87. 'theme_advanced_resize_horizontal' => true,
  88. 'theme_advanced_statusbar_location' => 'bottom',
  89. 'theme_advanced_toolbar_align' => 'left',
  90. 'theme_advanced_toolbar_location' => 'top',
  91. 'height' => $this->modx->getOption('gallery.tiny.height',null,200),
  92. 'width' => $this->modx->getOption('gallery.tiny.width',null,'95%'),
  93. 'tiny.custom_buttons1' => (!empty($cb1)) ? $cb1 : $this->modx->getOption('tiny.custom_buttons1',null,'undo,redo,selectall,separator,pastetext,pasteword,separator,search,replace,separator,nonbreaking,hr,charmap,separator,image,modxlink,unlink,anchor,media,separator,cleanup,removeformat,separator,fullscreen,print,code,help'),
  94. 'tiny.custom_buttons2' => (!empty($cb2)) ? $cb2 : $this->modx->getOption('tiny.custom_buttons2',null,'bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect,separator,styleprops'),
  95. 'tiny.custom_buttons3' => (!empty($cb3)) ? $cb3 : $this->modx->getOption('tiny.custom_buttons3',null,''),
  96. 'tiny.custom_buttons4' => (!empty($cb4)) ? $cb4 : $this->modx->getOption('tiny.custom_buttons4',null,''),
  97. 'tiny.custom_buttons5' => (!empty($cb5)) ? $cb5 : $this->modx->getOption('tiny.custom_buttons5',null,''),
  98. 'tiny.custom_plugins' => (!empty($plugins)) ? $plugins : $this->modx->getOption('tiny.custom_plugins',null,'style,advimage,advlink,modxlink,searchreplace,print,contextmenu,paste,fullscreen,noneditable,nonbreaking,xhtmlxtras,visualchars,media'),
  99. 'tiny.editor_theme' => (!empty($theme)) ? $theme : $this->modx->getOption('tiny.editor_theme',null,'cirkuit'),
  100. 'tiny.skin_variant' => $this->modx->getOption('tiny.skin_variant',null,''),
  101. 'tiny.theme_advanced_blockformats' => (!empty($bfs)) ? $bfs : $this->modx->getOption('tiny.theme_advanced_blockformats',null,'p,h1,h2,h3,h4,h5,h6,div,blockquote,code,pre,address'),
  102. 'tiny.css_selectors' => (!empty($css)) ? $css : $this->modx->getOption('tiny.css_selectors',null,''),
  103. );
  104. require_once $tinyCorePath.'tinymce.class.php';
  105. $tiny = new TinyMCE($this->modx,$tinyProperties);
  106. $tiny->setProperties($tinyProperties);
  107. $html = $tiny->initialize();
  108. $this->addHtml($html);
  109. }
  110. }
  111. }
  112. }