Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two useful features #242

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/components/gallery/js/mgr/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
16 changes: 9 additions & 7 deletions assets/components/gallery/js/mgr/widgets/album/album.panel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GAL.panel.Album = function(config) {
config = config || {};

Ext.apply(config,{
id: 'gal-panel-album'
,url: GAL.config.connector_url
Expand Down Expand Up @@ -51,6 +51,7 @@ GAL.panel.Album = function(config) {
,fieldLabel: _('description')
,name: 'description'
,anchor: '100%'
,id: 'gal-album-description'
}]
},{
columnWidth: .4
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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: {}
Expand Down Expand Up @@ -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);
Ext.reg('gal-panel-album-items',GAL.panel.AlbumItems);
77 changes: 76 additions & 1 deletion core/components/gallery/controllers/home.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'; }
}
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);
}
}
}

}
6 changes: 4 additions & 2 deletions core/components/gallery/elements/snippets/snippet.gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.');
Expand All @@ -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 '';
return '';
8 changes: 6 additions & 2 deletions core/components/gallery/model/gallery/galitem.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function set($k, $v= null, $vType= '') {
}
return parent::set($k,$v,$vType);
}

/**
* Upload a file to an album
*
Expand Down Expand Up @@ -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 {

Expand All @@ -273,6 +274,7 @@ public static function getList(modX &$modx,array $scriptProperties = array()) {
'id' => '',
'name' => '',
'description' => '',
'coverId' => '',
);

$tagc = $modx->newQuery('galTag');
Expand Down Expand Up @@ -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) {
Expand All @@ -355,4 +359,4 @@ public static function getList(modX &$modx,array $scriptProperties = array()) {
}
return $data;
}
}
}