diff --git a/assets/components/gallery/js/mgr/gallery.js b/assets/components/gallery/js/mgr/gallery.js index c2755e8..59f6052 100644 --- a/assets/components/gallery/js/mgr/gallery.js +++ b/assets/components/gallery/js/mgr/gallery.js @@ -91,7 +91,12 @@ GAL.window.CreateAlbum = function(config) { }] }); GAL.window.CreateAlbum.superclass.constructor.call(this,config); + this.on('activate',function() { + if (typeof Tiny != 'undefined') { MODx.loadRTE(this.ident + '-description'); } + }); + }; + Ext.extend(GAL.window.CreateAlbum,MODx.Window); Ext.reg('gal-window-album-create',GAL.window.CreateAlbum); diff --git a/assets/components/gallery/js/mgr/widgets/album/album.panel.js b/assets/components/gallery/js/mgr/widgets/album/album.panel.js index 5ffe1f1..528fdb5 100644 --- a/assets/components/gallery/js/mgr/widgets/album/album.panel.js +++ b/assets/components/gallery/js/mgr/widgets/album/album.panel.js @@ -1,6 +1,6 @@ GAL.panel.Album = function(config) { config = config || {}; - + Ext.apply(config,{ id: 'gal-panel-album' ,url: GAL.config.connector_url @@ -51,6 +51,7 @@ GAL.panel.Album = function(config) { ,fieldLabel: _('description') ,name: 'description' ,anchor: '100%' + ,id: 'gal-album-description' }] },{ columnWidth: .4 @@ -112,6 +113,7 @@ Ext.extend(GAL.panel.Album,MODx.FormPanel,{ initialized: false ,setup: function() { if (!this.config.album || this.initialized) return; + if (typeof Tiny != 'undefined') { MODx.loadRTE('gal-album-description'); } MODx.Ajax.request({ url: this.config.url ,params: { @@ -142,7 +144,7 @@ Ext.reg('gal-panel-album',GAL.panel.Album); GAL.panel.AlbumItems = function(config) { config = config || {}; - + this.view = MODx.load({ id: 'gal-album-items-view' ,xtype: 'gal-view-album-items' @@ -192,13 +194,13 @@ GAL.panel.AlbumItems = function(config) { ] }); var dv = this.view; - - + + dv.on('render', function() { dv.dragZone = new MODx.DataView.dragZone(dv); dv.dropZone = new MODx.DataView.dropZone(dv); }); - + Ext.applyIf(config,{ id: 'gal-panel-album-items' ,cls: 'browser-win' @@ -257,7 +259,7 @@ GAL.panel.AlbumItems = function(config) { }] }); GAL.panel.AlbumItems.superclass.constructor.call(this,config); - + }; Ext.extend(GAL.panel.AlbumItems,MODx.Panel,{ windows: {} @@ -337,4 +339,4 @@ Ext.extend(GAL.panel.AlbumItems,MODx.Panel,{ this.windows.zipUpload.show(e.target); } }); -Ext.reg('gal-panel-album-items',GAL.panel.AlbumItems); \ No newline at end of file +Ext.reg('gal-panel-album-items',GAL.panel.AlbumItems); diff --git a/core/components/gallery/controllers/home.class.php b/core/components/gallery/controllers/home.class.php index afe16ff..581a2e3 100644 --- a/core/components/gallery/controllers/home.class.php +++ b/core/components/gallery/controllers/home.class.php @@ -31,6 +31,81 @@ public function loadCustomCssJs() { $this->addJavascript($this->gallery->config['jsUrl'].'mgr/widgets/album/album.tree.js'); $this->addJavascript($this->gallery->config['jsUrl'].'mgr/widgets/home.panel.js'); $this->addLastJavascript($this->gallery->config['jsUrl'].'mgr/sections/home.js'); + $this->checkForTinyMCE(); } public function getTemplateFile() { return $this->gallery->config['templatesPath'].'home.tpl'; } -} \ No newline at end of file + public function checkForTinyMCE() { + /* If we want to use Tiny, we'll need some extra files. */ + $useTiny = $this->modx->getOption('gallery.use_richtext',$this->gallery->config,false); + if ($useTiny) { + $tinyCorePath = $this->modx->getOption('tiny.core_path',null,$this->modx->getOption('core_path').'components/tinymce/'); + if (file_exists($tinyCorePath.'tinymce.class.php')) { + + /* First fetch the gallery+tiny specific settings */ + $cb1 = $this->modx->getOption('gallery.tiny.buttons1',null,'undo,redo,selectall,pastetext,pasteword,charmap,separator,image,modxlink,unlink,media,separator,code,help'); + $cb2 = $this->modx->getOption('gallery.tiny.buttons2',null,'bold,italic,underline,strikethrough,sub,sup,separator,bullist,numlist,outdent,indent,separator,justifyleft,justifycenter,justifyright,justifyfull'); + $cb3 = $this->modx->getOption('gallery.tiny.buttons3',null,'styleselect,formatselect,separator,styleprops'); + $cb4 = $this->modx->getOption('gallery.tiny.buttons4',null,''); + $cb5 = $this->modx->getOption('gallery.tiny.buttons5',null,''); + $plugins = $this->modx->getOption('gallery.tiny.custom_plugins',null,''); + $theme = $this->modx->getOption('gallery.tiny.theme',null,''); + $bfs = $this->modx->getOption('gallery.tiny.theme_advanced_blockformats',null,''); + $css = $this->modx->getOption('gallery.tiny.theme_advanced_css_selectors',null,''); + + /** @var modAction $browserAction */ + $browserAction = $this->modx->getObject('modAction',array('controller' => 'browser')); + + /* If the settings are empty, override them with the generic tinymce settings. */ + $tinyProperties = array( + 'accessibility_warnings' => false, + 'browserUrl' => $browserAction ? $this->modx->getOption('manager_url',null,MODX_MANAGER_URL).'index.php?a='.$browserAction->get('id').'&source=1' : null, + 'cleanup' => true, + 'cleanup_on_startup' => false, + 'compressor' => '', + 'execcommand_callback' => 'Tiny.onExecCommand', + 'file_browser_callback' => 'Tiny.loadBrowser', + 'force_p_newlines' => true, + 'force_br_newlines' => false, + 'formats' => array( + 'alignleft' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyleft'), + 'alignright' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyright'), + 'alignfull' => array('selector' => 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', 'classes' => 'justifyfull'), + ), + 'frontend' => false, + 'plugin_insertdate_dateFormat' => '%Y-%m-%d', + 'plugin_insertdate_timeFormat' => '%H:%M:%S', + 'preformatted' => false, + 'resizable' => true, + 'relative_urls' => true, + 'remove_script_host' => true, + 'theme_advanced_disable' => '', + 'theme_advanced_resizing' => true, + 'theme_advanced_resize_horizontal' => true, + 'theme_advanced_statusbar_location' => 'bottom', + 'theme_advanced_toolbar_align' => 'left', + 'theme_advanced_toolbar_location' => 'top', + + + 'height' => $this->modx->getOption('gallery.tiny.height',null,200), + 'width' => $this->modx->getOption('gallery.tiny.width',null,'95%'), + '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'), + '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'), + 'tiny.custom_buttons3' => (!empty($cb3)) ? $cb3 : $this->modx->getOption('tiny.custom_buttons3',null,''), + 'tiny.custom_buttons4' => (!empty($cb4)) ? $cb4 : $this->modx->getOption('tiny.custom_buttons4',null,''), + 'tiny.custom_buttons5' => (!empty($cb5)) ? $cb5 : $this->modx->getOption('tiny.custom_buttons5',null,''), + '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'), + 'tiny.editor_theme' => (!empty($theme)) ? $theme : $this->modx->getOption('tiny.editor_theme',null,'cirkuit'), + 'tiny.skin_variant' => $this->modx->getOption('tiny.skin_variant',null,''), + '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'), + 'tiny.css_selectors' => (!empty($css)) ? $css : $this->modx->getOption('tiny.css_selectors',null,''), + ); + require_once $tinyCorePath.'tinymce.class.php'; + $tiny = new TinyMCE($this->modx,$tinyProperties); + $tiny->setProperties($tinyProperties); + $html = $tiny->initialize(); + $this->addHtml($html); + } + } + } + +} diff --git a/core/components/gallery/elements/snippets/snippet.gallery.php b/core/components/gallery/elements/snippets/snippet.gallery.php index 0154b5c..27c77fe 100644 --- a/core/components/gallery/elements/snippets/snippet.gallery.php +++ b/core/components/gallery/elements/snippets/snippet.gallery.php @@ -24,7 +24,7 @@ * * @var modX $modx * @var Gallery $gallery - * + * * @package gallery */ $gallery = $modx->getService('gallery','Gallery',$modx->getOption('gallery.core_path',null,$modx->getOption('core_path').'components/gallery/').'model/gallery/',$scriptProperties); @@ -153,6 +153,7 @@ $toPlaceholder.'.name' => $data['album']['name'], $toPlaceholder.'.description' => $data['album']['description'], $toPlaceholder.'.total' => $data['total'], + $toPlaceholder.'.coverId' => $data['coverId'], )); } else { $placeholderPrefix = $modx->getOption('placeholderPrefix',$scriptProperties,'gallery.'); @@ -161,7 +162,8 @@ $placeholderPrefix.'name' => $data['album']['name'], $placeholderPrefix.'description' => $data['album']['description'], $placeholderPrefix.'total' => $data['total'], + $placeHolderPrefix.'.coverId' => $data['coverId'], )); return $output; } -return ''; \ No newline at end of file +return ''; diff --git a/core/components/gallery/model/gallery/galitem.class.php b/core/components/gallery/model/gallery/galitem.class.php index 1dc9915..40c4961 100644 --- a/core/components/gallery/model/gallery/galitem.class.php +++ b/core/components/gallery/model/gallery/galitem.class.php @@ -121,7 +121,7 @@ public function set($k, $v= null, $vType= '') { } return parent::set($k,$v,$vType); } - + /** * Upload a file to an album * @@ -257,6 +257,7 @@ public static function getList(modX &$modx,array $scriptProperties = array()) { 'items' => $items, 'total' => $cache['total'], 'album' => $cache['album'], + 'coverId' => $cache['coverId'], ); } else { @@ -273,6 +274,7 @@ public static function getList(modX &$modx,array $scriptProperties = array()) { 'id' => '', 'name' => '', 'description' => '', + 'coverId' => '', ); $tagc = $modx->newQuery('galTag'); @@ -339,12 +341,14 @@ public static function getList(modX &$modx,array $scriptProperties = array()) { 'items' => $items, 'total' => $count, 'album' => $activeAlbum, + 'coverId' => $album->getCoverItem()->id, ); $cache = array( 'items' => array(), 'total' => $count, 'album' => $activeAlbum, + 'coverId' => $album->getCoverItem()->id, ); /** @var galItem $item */ foreach ($items as $item) { @@ -355,4 +359,4 @@ public static function getList(modX &$modx,array $scriptProperties = array()) { } return $data; } -} \ No newline at end of file +}