Skip to content

Commit

Permalink
[mikrobi#27][mikrobi#90][mikrobi#92] Refactor language selection, run…
Browse files Browse the repository at this point in the history
…s using AJAX

[mikrobi#83][mikrobi#59] extend babel plugin OnResourceDuplicate for nested resources
[mikrobi#67] italian translation
[mikrobi#60] Added Dutch translation
[mikrobi#58][mikrobi#64] Fixed the error with updating a resource, at least in the quick update window
  • Loading branch information
goldsky committed Nov 26, 2014
1 parent c8e24f2 commit a3f726a
Show file tree
Hide file tree
Showing 13 changed files with 744 additions and 356 deletions.
47 changes: 47 additions & 0 deletions assets/components/babel/conn/mgr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Babel
*
* Copyright 2010 by Jakob Class <jakob.class@class-zec.de>
*
* This file is part of Babel.
*
* Babel is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* Babel is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Babel; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* @package babel
*/
/**
* Babel AJAX connector in the manager.
*
* @author goldsky <goldsky@virtudraft.com>
*
* @package babel
*/

require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/config.core.php';
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CONNECTORS_PATH . 'index.php';

$corePath = $modx->getOption('babel.core_path', null, $modx->getOption('core_path') . 'components/babel/');
require_once $corePath . 'model/babel/babel.class.php';
$modx->babel = new Babel($modx);

$modx->lexicon->load('babel:default');

/* handle request */
$path = $modx->getOption('processorsPath', $modx->babel->config, $corePath . 'processors/');
$modx->request->handleRequest(array(
'processors_path' => $path,
'location' => '',
));
88 changes: 1 addition & 87 deletions assets/components/babel/css/babel.css
Original file line number Diff line number Diff line change
@@ -1,93 +1,7 @@
/**
* Babel CSS file
*
* @author Jakob Class <jakob.class@class-zec.de>
* @author goldsky <goldsky@virtudraft.com>
*
* @package babel
*/
#babel-box{
background: rgba(224, 224, 224, 0.75);
margin:15px 0 0;
padding:10px;
-moz-border-radius: 3px;
border-radius: 3px;
/*display: inline-block; */
position: fixed;
top: 124px;
right: 20px;
z-index: 12;
}
#babel-box a{
display:block;
padding:5px 12px 4px 12px;
background:#779937;
color:white;
text-decoration:none;
-moz-border-radius: 3px;
border-radius: 3px;
text-shadow: 0 2px 1px #666;
}

#babel-box div.selected a{
background:#666;
}
#babel-box div.notset a{
background:#999;
cursor:default;
}
#babel-box a:hover{
background:#628f2c;
}
#babel-box div.notset a:hover{
background:#999;
}
#babel-box div.babel-language {
position: relative;
float:left;
margin:0 12px 0 0;
}
#babel-box div.babel-language-layer {
z-index: 1000;
display: none;
position: absolute;
top: 24px;
right: 0;
padding:11px;
background:#ddd;
border: 1px solid #ccc;
-moz-border-radius: 4px;
border-radius: 4px;
-moz-box-shadow: 2px 2px 3px #666;
-webkit-box-shadow: 2px 2px 3px #666;
box-shadow: 2px 2px 3px #666;
/* For IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=3, Direction=135, Color='#666666')";
/* For IE 5.5 - 7 */
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=3, Direction=135, Color='#666666');
}
#babel-box input.x-form-text {
padding: 0 2px;
width: 20px;
font-size: 11px;
line-height: 18px;
margin-right: 5px;
}
#babel-box input.x-btn {
line-height: 14px;
padding: 3px;
margin: 2px 0;
}
#babel-second-row {
white-space: nowrap;
}
#babel-error{
padding-bottom:10px;
color: red;
font-weight: bold;
}
#babel-box hr {
margin: 8px 0;
}
#babel-box strong {
font-weight: bold;
}
205 changes: 205 additions & 0 deletions assets/components/babel/js/babel.class.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
/**
* Babel
*
* Copyright 2010 by Jakob Class <jakob.class@class-zec.de>
*
* This file is part of Babel.
*
* Babel is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* Babel is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* Babel; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*
* @package babel
*/
/**
* Babel JavaScript class file for the menu in the manager.
*
* @author goldsky <goldsky@virtudraft.com>
*
* @package babel
*/

function Babel(config) {
this.config = config;
}

Babel.prototype.getMenu = function (menus) {
var actionButtons = Ext.getCmp("modx-action-buttons");
if (actionButtons) {
var menu = [];
for (ctx in menus) {
if (typeof(menus[ctx]["resourceUrl"]) !== 'undefined' &&
menus[ctx]["resourceUrl"] !== "" &&
menus[ctx]["resourceUrl"] !== "#" ) {
if (ctx === Babel.config.context_key) {
continue;
}
menu.push({
text: menus[ctx]["displayText"],
menu: {
items: [
{
text: _('babel.open') + " <b>" + menus[ctx]["resourceTitle"] + " (" + menus[ctx]["resourceId"] + ")</b>",
resourceUrl: menus[ctx]["resourceUrl"],
handler: function() {
window.location.href = window.location.origin + window.location.pathname + this.resourceUrl;
}
}, '-', {
text: _('babel.unlink') + " <b>" + menus[ctx]["resourceTitle"] + " (" + menus[ctx]["resourceId"] + ")</b>",
contextKey: ctx,
target: menus[ctx]["resourceId"],
handler: function() {
Babel.unlinkTranslation(this.contextKey, MODx.request.id, this.target);
}
}
]
}
});
} else {
menu.push({
text: menus[ctx]["displayText"],
handler: Ext.emptyFn,
menu: {
items: [
{
text: _('babel.create_translation'),
contextKey: ctx,
handler: function() {
Babel.createTranslation(this.contextKey, MODx.request.id);
}
}, '-', {
text: _('babel.link_translation'),
contextKey: ctx,
handler: function() {
Babel.linkTranslation(this.contextKey, MODx.request.id);
}
}
]
}
});
}
}
var buttonMenu = new Ext.Button({
text: 'Select Language',
menu: menu,
listeners: {
render: {
fn: function (btn) {
btn.setText(menus[Babel.config.context_key]["displayText"]);
},
scope: this
}
}
});
actionButtons.insertButton(0, [buttonMenu, "-"]);
actionButtons.doLayout();
}
};

Babel.prototype.linkTranslation = function (ctx, id) {
var win = MODx.load({
xtype: 'modx-window',
title: _('babel.link_translation'),
url: Babel.config.connector_url,
baseParams: {
action: 'mgr/resource/link',
context: ctx,
id: id
},
listeners: {
'success': {
fn: function (r) {
MODx.msg.status({
title: _('success'),
message: r.message || _('save_successful')
});
},
scope: this}
},
fields: [
{
xtype: 'textfield',
fieldLabel: _('context'),
disabled: true,
emptyText: ctx
}, {
xtype: 'hidden',
name: 'target'
}, {
xtype: 'modx-field-parent-change',
fieldLabel: _('babel.id_of_target'),
id: '',
width: 370,
name: 'target-combo',
end: function (p) {
var t = Ext.getCmp('modx-resource-tree');
if (!t)
return;
p.d = p.d || p.v;
win.fp.getForm().findField('target').setValue(p.v);
this.setValue(p.d);
this.oldValue = false;
}
}, {
xtype: 'xcheckbox',
boxLabel: _('babel.copy_tv_values'),
name: 'copy-tv-values'
}
]
});
win.reset();
win.show();
};

Babel.prototype.unlinkTranslation = function (ctx, id, target) {
return MODx.msg.confirm({
title: _('confirm'),
text: _('babel.unlink_translation_confirm', {context: ctx, id: id}),
url: Babel.config.connector_url,
params: {
action: 'mgr/resource/unlink',
context: ctx,
id: id,
target: target
},
listeners: {
'success': {
fn: function (r) {
MODx.msg.status({
title: _('success'),
message: r.message || _('save_successful')
});
},
scope: this}
}
});
};

Babel.prototype.createTranslation = function (ctx, id) {
return MODx.msg.confirm({
title: _('confirm'),
text: _('babel.create_translation_confirm', {context: ctx, id: id}),
url: Babel.config.connector_url,
params: {
action: 'mgr/resource/duplicate',
context_key: ctx,
id: id
},
listeners: {
'success': {
fn: function (r) {
MODx.loadPage('resource/update', 'id=' + r.object.id);
},
scope: this}
}
});
};
16 changes: 6 additions & 10 deletions assets/components/babel/js/babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Babel
*
* Copyright 2010 by Jakob Class <jakob.class@class-zec.de>
*
*
* This file is part of Babel.
*
* Babel is free software; you can redistribute it and/or modify it under the
Expand All @@ -21,17 +21,13 @@
* @package babel
*/
/**
* Babel JavaScript file for the babel-box in the manager.
* Babel JavaScript file for the menu in the manager.
*
* @author Jakob Class <jakob.class@class-zec.de>
* @author goldsky <goldsky@virtudraft.com>
*
* @package babel
*/
Ext.onReady(function() {
Ext.select('div.babel-language:has(.babel-language-layer)').on('mouseenter', function(){
Ext.get(this).child('.babel-language-layer').show();
})
.on('mouseleave', function(){
Ext.get(this).child('.babel-language-layer').hide();
});

Ext.onReady(function () {
Babel.getMenu(Babel.config.menu);
});
8 changes: 8 additions & 0 deletions core/components/babel/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Changelog for Babel.

Babel 3.0.0-dev
==============
- [#27][#90][#92] Refactor language selection, runs using AJAX
- [#83][#59] extend babel plugin OnResourceDuplicate for nested resources
- [#67] italian translation
- [#60] Added Dutch translation
- [#58][#64] Fixed the error with updating a resource, at least in the quick update window

Babel 2.2.5-pl
==============
- Extended list of languages in translation files and added Romanian translation.
Expand Down
Loading

0 comments on commit a3f726a

Please sign in to comment.